[slf4j-dev] MDC Type functionality
John E. Conlon
jconlon at verticon.com
Mon Mar 26 23:26:28 CEST 2007
Gardiner, Paul wrote:
> The extended log service in equinox is similar to the standard one, but
> it adds a few extra methods for supporting named loggers, isLoggable,
> and logging context objects. Here's the basic idea:
> https://www.eclipse.org/bugs/show_bug.cgi?id=147824. It's just an
> incubator project right now, but I have a pressing need at the moment.
>
Interesting thread... I think our devs and users may find it most
interesting as slf4j is mentioned several times: :-)
For example:
> Message payload for the LogService consistes primarily of String based messages
> and when relevant a Throwable. In some situations a generic String-based
> logging API is insufficient and in these cases it's desirable to pass additonal
> information with the understanding that it may be ignored. SLF4J uses it's
> Marker API in this fashion to allow strong coupling between logger and
> recipient without impacting the generic log API.
...
> For this to work there are a couple of problems that need thought:
> 1) we need a binding of the various logging API to the log service
> - we should consider looking at SLF4J as its defined a few useful static
> bindings already for JCL and log4j.
...
> I'm step by step migrating to SLF4J, because I really enjoy the simplicity and
> effectiveness of the API. Problem is: I NEED to know which OSGi Plugin is
> logging. This is a serious problem, as all implementations only provide a
> thread based context.
Note: The osgi-over-slf4j binding in the repo already provides this information as BundleSymbolicName and Version.
> I'm new to SLF4J, but I have looked around at markers, and found there
> isn't a lot of info on how they are used.
Logger logger = LoggerFactory.getLogger("testMarker");
Marker blue = MarkerFactory.getMarker("BLUE");
logger.debug(blue, "hello");
logger.info(blue, "hello");
logger.warn(blue, "hello");
logger.error(blue, "hello");
Take a look at the test cases in slf4j.
> It looks like a single piece
> of data, but with a hierarchy.
Yes.
> How would it work in this case? Would I
> (or the end user) create a marker named "session_id", and then create a
> child with the actual session id as the name?
>
>
Well from what I gather about the Equinox extension is that there is a
context associated with logging messages.
In your use case the user or client application is an Equinox Log
Service client, not a slf4j api user right? That would mean YOU would
have to create the Marker from the context in the log messages in your
'equinox-over-slf4j'.
Now the critical question is which Logging API implementation are you
planning to have your 'equinox-over-slf4j' bind with? If you use Markers
you will have to use an implementation that uses them too and that would
be either one that you implement or the Logback implementation. Check
the logback project for more details on how it handles marker
hierarchies. http://logback.qos.ch/
cheers,
John
>
> -----Original Message-----
> From: dev-bounces at slf4j.org [mailto:dev-bounces at slf4j.org] On Behalf Of
> John E. Conlon
> Sent: Monday, March 26, 2007 12:55 PM
> To: slf4j developers list
> Subject: Re: [slf4j-dev] MDC Type functionality
>
> 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
>>
>>
>>
> ------------------------------------------------------------------------
>
>> _______________________________________________
>> dev mailing list
>> dev at slf4j.org
>> http://www.slf4j.org/mailman/listinfo/dev
>>
>
> _______________________________________________
> dev mailing list
> dev at slf4j.org
> http://www.slf4j.org/mailman/listinfo/dev
> _______________________________________________
> dev mailing list
> dev at slf4j.org
> http://www.slf4j.org/mailman/listinfo/dev
>
>
>
More information about the slf4j-dev
mailing list