
22 Nov
2011
22 Nov
'11
3:59 a.m.
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