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

interfries at yahoo.de interfries at yahoo.de
Thu Aug 30 18:54:19 CEST 2007


Hi everybody,

I'm not quite sure whether InheritableThreadLocal
works for PooledExecutors with pre-forked Threads.
Because afai understand InheritableThreadLocal shares
the context with the creating thread but that must not
be the thread that issues a runnable into a
PoolExecutor. But as I said, I'm not quite sure.

--- Ceki Gulcu <listid at qos.ch> schrieb:

> Hi Peter,
> 
> Java offers the notion of "inheritable thread local"
> data which would take 
> conveying MDC data to child threads. There is even a
> bug report on this issue:
> 
>    http://bugzilla.qos.ch/show_bug.cgi?id=64
> 
> Would the solution described in bug 64 (above) work
> for you?
> 
> Cheers,
> 
> peter huber wrote:
> >   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
> > lost. 
> > 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() {
> >    MDC.setMemento(myMemento);
> >    mySubject.run();
> >    MDC.clear();
> > }
> > 
> > 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
> > 
> > _______________________________________________
> > logback-dev mailing list
> > logback-dev at qos.ch
> > http://qos.ch/mailman/listinfo/logback-dev
> 
> -- 
> Ceki Gülcü
> Logback: The reliable, generic, fast and flexible
> logging framework for Java.
> http://logback.qos.ch
> _______________________________________________
> logback-dev mailing list
> logback-dev at qos.ch
> http://qos.ch/mailman/listinfo/logback-dev
> 



      __________________________________  
Yahoo! Clever: Sie haben Fragen? Yahoo! Nutzer antworten Ihnen. www.yahoo.de/clever




More information about the logback-dev mailing list