[slf4j-dev] Plan for SLF4J 2.0

Gunnar Wagenknecht gunnar at wagenknecht.org
Tue Mar 9 17:00:42 CET 2010


Am 09.03.2010 12:20, schrieb Joern Huxhorn:
> Much like an ordinary stack-trace, the NDC is actually a stack. The  
> stacking of messages is the key here.

I know. But looking at your examples, I don't see something that the
current Java stack trace wouldn't give me already. The logging of method
arguments might be key here but a stack only really makes sense if you
use recursion. Another issue is that the API usage is quite complicated
for clients. They need to wrap each usage into try/finally blocks.

However, I can see some value in having both - a simple to use MDC as
well as an NDC. I wonder if it's possible to merge both into a central
API "DiagnoseContext" or just DC.

> The main difference between the MDC and (my implementation of) the NDC  
> is that NDC is also supporting the same Message as the one I proposed  
> for logging in general. This means, that the actual formatting of the  
> message isn't performed if it's not really needed (for example, if the  
> Appenders in Logback are not printing the NDC but choose to ignore it).

That's just an implementation detail. MDC can be changed as well.
Remember, we are talking about a version 2.0 which means breaking API
changes anyway.

> With MDC, on the other hand, one would have to format the message  
> anyway.

Deferring formatting is good (performance wise). I think such a message
class (under the covers) should be a key concept in SLF4J 2.0.

-Gunnar

-- 
Gunnar Wagenknecht
gunnar at wagenknecht.org
http://wagenknecht.org/



More information about the slf4j-dev mailing list