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

Durchholz, Joachim Joachim.Durchholz at hennig-fahrzeugteile.de
Fri Feb 26 13:27:50 CET 2010


> (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