org.slf4j.NDC implementation problem

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

Hi Antony, Could you please enter a bug report so that when the patch is applied it can be associated with a bug number? -- Ceki On 22.11.2011 04:59, Antony Bowesman wrote:
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. a
Is there any reason why this cannot be taken to the core code? Antony

Hi Ceki, http://bugzilla.slf4j.org/show_bug.cgi?id=253 I had no use case for any of the other log4j NDC methods, but it could be worth having a basic implementation of them. Antony On 22/11/2011 5:36 PM, Ceki Gulcu wrote:
Hi Antony,
Could you please enter a bug report so that when the patch is applied it can be associated with a bug number?
-- Ceki
participants (2)
-
Antony Bowesman
-
Ceki Gulcu