[slf4j-dev] MDC Type functionality

Gardiner, Paul PGardiner at syntellect.com
Mon Mar 26 21:05:20 CEST 2007


Actually, I'm really just looking for a solution to the problem, not really suggesting that MDC is the answer.  If there is a better way of achieving the same thing, that would be great.

As you said, a different thread will be writing out the logs, however, the logger thread (which writes to the OSGi log) could read the MDC data and send it through to the OSGi logger as a map, or some other unrelated object, and the log reader could then set MDC using log4j or logback, or just ignore it.  

I am surprised that there isn't a lot of demand for MDC. We use it all the time, and many of our customers do also.

-----Original Message-----
From: dev-bounces at slf4j.org [mailto:dev-bounces at slf4j.org] On Behalf Of Ceki Gülcü
Sent: Monday, March 26, 2007 2:52 PM
To: slf4j developers list
Subject: Re: [slf4j-dev] MDC Type functionality


Paul,

Would it help if SLF4J implemented a facade for MDC? Both logback and log4j 
1.3 (and above) implement MDC in the same way. Given lack of demand and 
that compared to log requests there are much fewer MDC calls, we decided 
not to include a facade for MDC in SLF4J. However, such support could be 
included if there is interest from the user community.

Reading a recent thread in equinox dev [1], it looks like log service is 
run from a different thread than the thread issuing the log request. I am 
not sure how MDC support in SLF4J support could help you...

[1] 
http://thread.gmane.org/gmane.comp.ide.eclipse.equinox.devel/1512/focus=1513

At 06:55 PM 3/26/2007, John E. Conlon wrote:
>Hello Paul,
>
>Have you considered using the
>
>
>     org.slf4j.Marker
>
>to move this data to the readers? See the FAQ
>http://www.slf4j.org/faq.html#marker_interface
>
>BTW - You may have noticed in our slf4j source repository we have
>implemented a simple osgi log service for slf4j?
>http://svn.slf4j.org/viewvc/slf4j/trunk/osgi-over-slf4j/
>
>I have not worked with the Equinox log service but plan to do so soon.
>Paul would you be so kind to please provide a link to the documentation
>that can describe the Equinox extensions? Is this log service the same
>used by Eclipse as well?
>
>thanks,
>John
>
>
>Gardiner, Paul wrote:
> >
> > I have written an SLF4J binding to the Equinox extended log service,
> > which is an extension of the OSGi logging service, that includes
> > contextual information, and passes "isLoggable" statements through to
> > log listeners (readers). The problem I have is supporting extra data
> > that is not part of the log message. SLF4J does not include MDC or NDC
> > functionality, so I am not sure of the best way to pass through this
> > kind of data. A typical use case is session id, which is passed as
> > MDC. When the log entry is made, the session id is included in the
> > file appender, but omitted from an appender that sends pages. One
> > solution is to read all MDC data and pass it through to the OSGi log
> > service, and then recreate it in the log reader. However, I was
> > wondering if there was a more elegant/less expensive solution.
> >
> > Thanks,
> >
> > Paul
> >
> > ------------------------------------------------------------------------
> >

-- 
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch

_______________________________________________
dev mailing list
dev at slf4j.org
http://www.slf4j.org/mailman/listinfo/dev



More information about the slf4j-dev mailing list