[slf4j-user] basic MDC support for java.util.logging
Ceki Gulcu
listid at qos.ch
Wed Oct 10 21:31:23 CEST 2007
Hi Maarteen,
Comments inline.
Maarten Bosteels wrote:
[snip]
> But unfortunately, not all SLF4J implementations (or adapters) support
> the MDC mechanism.
Indeed.
> Would it be acceptable to add basic MDC support to JDK14LoggerAdapter ?
Yes, it would.
> The MDC would store its key/value pairs in a ThreadLocal and JDK14LoggerAdapter
> could prepend these key/values to the msg (the same could be done for
> SimpleLogger).
If we did that, JDK14LoggerAdapter would be at least partially assuming the
responsibility for formatting the log message which seems kind of wrong to me.
> Another option would be to make subclasses of java.util.logging.XMLFormatter
> and java.util.logging.SimpleFormatter that are MDC aware.
Yah, that's better.
> (IMHO these classes don't have to be part of SLF4J)
Right.
> Then JDK14LoggerAdapter wouldn't have to change.
> It would be sufficient to change
> http://svn.slf4j.org/viewvc/slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/StaticMDCBinder.java
Nice.
> I am willing to create a patch, if there's a chance it would be accepted :-)
+1
> Note that I have almost no experience with java.util.logging.
> I am just trying to find a solution for libraries/frameworks that want
> to use org.slf4j.MDC
> without leaving users of java.util.logging in the cold.
Sounds like a plan.
> Thanks,
> Maarten
--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch
More information about the slf4j-user
mailing list