[logback-dev] MDC good concept but...Thread-Support

peter huber interfries at yahoo.de
Wed Aug 29 22:43:32 CEST 2007

  Hi LogBack-Team,

just want to tell you that MDC lacks thread support.
But I'm quite sure that you know that. As soon as you
"leave" a thread the MDC conext (ThreadLocal) will be
I had implemented something similar to MDC a while ago
and I accompanied my impl with a
ContextPreservingRunnable after a while. 

Works like this

CTOR (Source Thread):
ContextPreservingRunnable(Runnable inSubject) {
   myMemento = MDC.getMemento();
   mySubject = inSubject;

RUN-Method (Target Thread):
void run() {

Even though it works for me, it's rather bad that you
have to wrap all Runnables and Callables respectively.

Maybe a ExecutorFacade might server the purpose?

BTW: Does MDC include support for a Subjects
Principals (JAAS)...Please forgive me my showing off
at dev list;-)

Yahoo! Clever - Der einfachste Weg, Fragen zu stellen und Wissenswertes mit Anderen zu teilen. www.yahoo.de/clever

More information about the logback-dev mailing list