Delegate ScopedContext functionality to interface#2445
Conversation
To provide more configurability for the `ScopedContext` service, this PR moves its implementation details to `log4j-core` and replaces it with a `ScopedContextProvider` interface. In Log4j API only a NO-OP version of the provider is present, but each implementation of the API can provide its own.
|
I took a look at this again. I missed some things the first time through it. I like most of this but will want to change it a bit. |
Feel free to directly modify this branch. |
|
Rats. I didn't mean to but I merged my changes to this branch by mistake. They are now in the ScopedContext branch as well. I have a question though. I just noticed that you made the default ThreadContext provider a no-op. How did that manage to pass unit tests? Why does it need to be a no-op. For one, SimpleLogger includes the MDC in the output so I would think anyone using it would expect it to work. |
I removed Since I was mostly concerned with |
|
I disagree with your premise. SimpleLogger has always supported logging the ThreadContext. Including the ScopedContext as well makes sense since they can be interchangeably used. You adding a Noop implementation of ThreadContext essentially breaks backward compatibility. We need a minimal implementation in the API. |
To provide more configurability for the
ScopedContextservice, this PR moves its implementation details tolog4j-coreand replaces it with aScopedContextProviderinterface.In Log4j API only a NO-OP version of the provider is present, but each implementation of the API can provide its own.