[logback-dev] [JIRA] Created: (LBCLASSIC-188) Make table andcolumn names overridable

Ceki Gulcu ceki at qos.ch
Fri Feb 26 13:37:21 CET 2010


I appreciate the input although considering that DBNameResolver is a 
mere component of DBAppender, using generics in this case is probably 
not the best design one can come up with.

On 26.02.2010 13:27, Durchholz, Joachim wrote:
>> (If logback can use generic classes, then
>> DBAppender<DBNameResolver>  would be optimal IMHO.)
>
> Right, http://logback.qos.ch/dependencies.html says Java 1.5.
>
> Here's a design outline with generics.
> I left out enums because I'm not so sure whether they're such a great
> idea after all, and because it works just fine without them :)
>
> First, the base class:
>
> class DBAppender<DBNameResolver>  {
>    // Uses dbNameResolver.getEventTableName etc.
> }
> class DBNameResolver {
>    String getEventTableName ()             { return "logging_event"; }
>    String getTimestampColumnName ()        { return "timestmp"; }
>    String getFormattedMessageColumnName () { return "formatted_message";
> }
>    ...
>    String getEventPropertyTableName ()  { return
> "logging_event_property"; }
>    ...
>    String getEventExceptionTableName () { return
> "logging_event_exception"; }
>    ...
> }
>
> A variant for storing log parameters:
>
> class DBAppenderWithParameters<DbNameResolverWithParameters>  {
>    // Uses new dbNameResolver function getArgumentColumnNames
>    // to construct the INSERT statement
> }
> class DbNameResolverWithParameters extends DBNameResolver {
>    // Keep inherited definitions, just add the parameter column names
>    String [] argumentColumnNames = new String []
>      {"arg1", "arg2", "arg3", "arg4", "arg5", "arg5", "arg7", "arg8"};
>    String [] getArgumentColumnNames { return argumentColumNames; }
> }
>
> HTH
> Jo


More information about the logback-dev mailing list