[logback-user] Logback with Tomcat and multiple web applications

Ceki Gulcu ceki at qos.ch
Wed Feb 11 19:19:23 CET 2009

Hi Ryan,

I didn't quite understand why you needed ContextJNDISelector.
Anyway, here is documentation on MDC


Here is a salient paragraph from that page:

The MDC class contains only static methods. It lets the developer place 
information in a diagnostic context that can be subsequently retrieved by 
certain logback components. The MDC manages contextual information on a per 
thread basis. *A child thread automatically inherits a copy of the mapped 
diagnostic context of its parent*


Ryan Cornia wrote:
> Thanks for the suggestions, this is exactly what I want to do. As long as I
> can point ContextJNDISelector to an external config file, it sounds perfect.
> I assume I just put in the full path to get at a resource outside of the
> war? 
> I have tried setting MDC with log4j in the first Listener for a web app.
> This, unfortunately, has led to unpredictable results. Sometimes it comes
> through, sometimes not. We are running on a Tomcat 6 cluster. I'll give
> Logback a try, and hope the dropping MDC is a log4j issue. I had suspected
> maybe it was the way tomcat created threads that the parent MDC was
> sometimes not propagating.
> I assume setting the MDC in the first <listener> in web.xml should make it
> globally available, and applied to all logging statements?
> Thanks!

Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.

More information about the Logback-user mailing list