Hi,

I'm using logback's MDC to setup some logging info accross my application
(jsessionid and other stuff). Our application uses lots of @Asynchronous
methods. Since logback 1.1.3 MDC context is not propagated to child threads.

Is there any way to customise the asynchronous thread pool executor so I can
propagate manually the context as logback docs says?

/MDC And Managed Threads

A copy of the mapped diagnostic context can not always be inherited by
worker threads from the initiating thread. This is the case when
java.util.concurrent.Executors is used for thread management. For instance,
newCachedThreadPool method creates a ThreadPoolExecutor and like other
thread pooling code, it has intricate thread creation logic.

In such cases, it is recommended that MDC.getCopyOfContextMap() is invoked
on the original (master) thread before submitting a task to the executor.
When the task runs, as its first action, it should invoke
MDC.setContextMapValues() to associate the stored copy of the original MDC
values with the new Executor managed thread./

(or should I just forget MDC and think of another "context" mechanism?)



--
View this message in context: 
http://tomee-openejb.979440.n4.nabble.com/MDC-and-Asynchronous-tp4680927.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Reply via email to