[slf4j-user] basic MDC support for java.util.logging
Ceki Gulcu
listid at qos.ch
Fri Oct 19 15:15:27 CEST 2007
Hi Maarteen,
Comments inline.
Maarten Bosteels wrote:
> Hello Ceki,
>
> I started coding a BasicMDCAdapter that could be used by java.util.logging
> Had a look at the log4j MDC implementation and also at LogbackMDCAdapter code.
>
> Currently my implementation is roughly the same as the LogbackMDCAdapter
> without the generics (since SLF4J should run on 1.4 right ?)
Yes, SLF4J must run under JDK 1.4 or later.
> I didn't quite understand this remark in the code:
> * Each time a value is added, a new instance of the map is created. This is
> * to be certain that the serialization process will operate on the updated map
> * and not send a reference to the old map, thus not allowing the remote
> logback
> * component to see the latest changes.
That's an implementation detail in logback. You can safely ignore it
for JUL.
> Can you describe a scenario where serialization would fail if one just add a
value to the map ?
> Is it a threading issue ?
No, it's not a threading issue. As mentioned previously, you can ignore the
aforementioned comments in logback code.
[snip]
> It would be cool if logback would also have an Log4jXmlLayout. I think the
xml layout has several advantages over serialization:
> * it's more compact (much to me surprise) certainly when combined with a
GZipOutputStream
> * human readable
> * easier to implement in other languages (eg. log4cxx)
> * no need to depend on log4j's LoggingEvent
> * protected against changes to the serialized form of log4j's LoggingEvent
> for example, Chainsaw currently only displays the MDC when the sender is
using log4j 1.3
>
> It would be trivial to write, I am willing to implement it, if there's a
chance you will add it to logback.
In light of what you describe, I think using XML as an exchange format is quite
reasonable. More importantly, it remains aligned with SLF4J's goal of
abstracting/bridging logging systems.
You mention performance related results comparing XML formatting and Java
serialization. I'd be interested in the figures.
ps: I'll be away for two weeks and without internet access.
> regards,
> 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