[logback-user] How to direct calls to another API into Logback classic

Ceki Gülcü ceki at qos.ch
Tue Jun 7 23:58:32 CEST 2011


Hi Christopher,

Have a look at slf4j's XLogger [1] class. Note that it subclasses
LoggerWrapper [2] which is responsible for most of the delegation work 
and preservation of caller origin.

Shout if things remain unclear,

--
Ceki

[1] http://slf4j.org/xref/org/slf4j/ext/XLogger.html
[2] http://slf4j.org/xref/org/slf4j/ext/LoggerWrapper.html

On 07/06/2011 10:02 PM, Christopher BROWN wrote:
> Hello,
>
> I'm using Logback classic via the SLF4J API, in a big application
> where other log APIs (some standard, such as OSGI logging, and other
> proprietary in-house historical APIs) are present.
>
> I would like to re-implement these APIs to "redirect" onto Logback
> classic, but to get to the point: it's a big API and I'm lost.  If I
> reimplement said APIs with a naive implementation that just calls into
> SLF4J or logback using the "user" API, I'll incur an extra stack frame
> in stack traces and generally hide the origin of calls.
>
> What's the best, cleanest way of doing this (given SLF4J and the
> choice of logback classic) ?  I will add the Log4J API implementation
> to address some cases (the SLF4J implementation of Log4J APIs) but for
> the other stuff, I'm a bit stuck.
>
> Thanks,
> Christopher


More information about the Logback-user mailing list