[logback-dev] Logback extensibility design.

Gabriele Contini contini.mailing at gmail.com
Mon Nov 2 17:57:15 CET 2009


Hi,
I was facing a problem with Logback (the one described here 
http://jira.qos.ch/browse/LBCLASSIC-166), and i tried to extend the 
design of logback to implement this new feature without modifing the 
existing code.

I found only one pre-defined extension point: the ContextSelector 
mechanism. But however i turn around the problem i can't extend Logback 
functionality without modifying the library.

I think a "base library" should be extensible to fit different user 
needs and not "blocked" to extensions.

The problems i've found are the following:

* In my opinion LoggerContext should be (where possible) changed into 
ILoggerFactory in ContextSelector interface. Thus allowing for user 
defined LoggerContext implementation to be plugged in.

* Moreover LoggerContext.getLogger(String) shouldn't be final, allowing 
users to subclass the LoggerContext and provide their own loggers 
implementation. It should also return an instance of org.slf4j.Logger as 
defined in ILoggerFactory interface (and not an 
ch.qos.logback.classic.Logger that's final and unchangeable).

* At this stage of my work i cant' understand if i'll need to subclass 
ch.qos.logback.classic.Logger or i can just implement a org.slf4j.Logger 
that forwards his calls to a ch.qos.logback.classic.Logger instance. 
Anyway I'm sure that my work would be easier if 
ch.qos.logback.classic.Logger is not final.

Best regards.
Gabriele Contini



More information about the logback-dev mailing list