[logback-user] Separating the logging-output of libraries in tomcat/shared

Achim Wiedemann awn at inxmail.de
Fri Feb 26 08:21:45 CET 2010


Hey everybody,

just wanted to port our application from commons-logging / log4j to 
slf4j / logback. Unfortunately I stumbled upon some problems when 
separating the logging-output from different webapps (using the 
JNDIContextSelector). As long as you only use logging from classes 
inside the webapp, everything works fine. But as soon as you've got 
classes in tomcat/shared which use logging, you run into trouble: All 
logging output of the shared classes (e.g. Spring) are directed to the 
logger-context of the webapp which first loads the (shared) class.

Example: Let's say you've got webbapp [A], webbapp [B], and Spring in 
tomcat/shared. Now both webapps use Spring. If webapp [B] first accesses 
any classes of Spring, all output of Spring will be directed to the 
log-file of [B], no matter from which webapp Spring is used. This is 
because static Logger references are used in Spring (which is 
commonplace) and are initialized with the context of webapp [B].

The issue is already described very well in the logback JIRA: 
http://jira.qos.ch/browse/LBCLASSIC-166

I wondered if anyone can make a suggestion how to deal with this. Any 
advice, tricks or magic is welcome. ;)


Thanks a lot,
Achim


More information about the Logback-user mailing list