[slf4j-user] basic MDC support for java.util.logging
Maarten Bosteels
mbosteels.dns at gmail.com
Tue Jan 8 13:43:44 CET 2008
Hello Ceki et al.
Have you had time to look at http://bugzilla.slf4j.org/show_bug.cgi?id=63 ?
AFAICS the patch is complete.
The included Log4jXmlFormatter has one important limit: the MDC
properties will only be correct when format() is called from the same
thread that generated the LogRecord. (as indicated by the javadoc).
We are getting close to MINA-2.0-M1 and it would be great if we could
simply drop our IoSessionLogger
in favor of the much more poweful MDC mechanism.
Thanks,
Maarten
On Oct 19, 2007 2:15 PM, Ceki Gulcu <listid at qos.ch> wrote:
>
> 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
> _______________________________________________
> user mailing list
> user at slf4j.org
> http://www.slf4j.org/mailman/listinfo/user
More information about the slf4j-user
mailing list