[slf4j-dev] org.slf4j.NDC implementation problem

Antony Bowesman adb at thorntothehorn.org
Tue Nov 22 04:59:37 CET 2011


I'm migrating a log4j environment to SLF4J.  Our log4j usage makes use of NDC as 
a small stack and I'm using the ext package to use the slf4j NDC.

However, the problem is that the NDC implementation just sits on top of MDC and 
the MDC context is inherited by threads, whereas NDC is NOT, unless inherit() is 
called specifically.

I then went to patch my NDC usage to call NDC.clear(), but the org.slf4j.NDC 
does not expose it.

This means the log output contains the NDC context from my root thread and 
there's no way to clear any of the context.

So, I have patched NDC as attached.

Is there any reason why this cannot be taken to the core code?
Antony

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: NDC.patch
URL: <http://mailman.qos.ch/pipermail/slf4j-dev/attachments/20111122/927befed/attachment.ksh>


More information about the slf4j-dev mailing list