[logback-dev] App Servers and Thread.contextClassLoader

Robert Elliot rob at lidalia.org.uk
Tue Jul 28 14:24:12 CEST 2009


Hello,

Slightly odd question, but it is logback related.  I'm writing a library to redirect System.out and System.err to SLF4J.  I'm envisaging this being used in application servers.  I'd like it to work "correctly" with SLF4J implementations like Logback, so if the app server has child first class loading and SLF4J and logback are in webapp A's lib dir, a call to System.out.println within webapp A will be handled as per the logback.xml in webapp A's classes folder, regardless of other webapps with different config.

The only way that is possible (as far as I can see) is to work out from the thread calling the System.out methods which web app it was that made the call - and I've found the method getContextClassLoader on Thread which looks hopeful!  However, I'm not completely confident that app servers that implement child first class loading will set that to the a web app specific class loader.

Does anyone know?  Do some app servers use this, and others not?  Might save me considerable experimentation time if this is well known info that I just don't happen to know yet.

Thanks,
Rob


More information about the logback-dev mailing list