You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2010/12/15 14:56:09 UTC

Intercepting log messages: LogListener and slf4j vs. LogService

Hi,

I'm playing with LogReaderService [1] with the goal of intercepting
and selectively persisting some log messages, ideally without changing
existing components.

Before I dig too deep: am I right that our OSGi LogService and slf4j
logging are two separate things, with no connection between them?

I thought we had a bridge between them, but at first sight it doesn't
seem like it: my LogListener only gets messages sent directly to the
LogService, and nothing that's sent using slf4j interfaces.

-Bertrand

[1] http://www.osgi.org/javadoc/r4v42/org/osgi/service/log/LogReaderService.html

Re: Intercepting log messages: LogListener and slf4j vs. LogService

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Bertrand

Yes LogReaderService is part of the OSGi Log Service spec and it only
gets messages sent to the LogService.

The LogService itself logs to SLF4J. Everything else (Log4J, Commons
Logging and SLF4J itself) also log to SLF4J but do not pass through the
LogService.

Maybe your problem could be solved with a custom LogWriter (or
appender). But this requires internal rewrites.

Once we convert our own SLF4J SPI impl. by LogBack (or something else),
we could then do such an interceptor.

Regards
Felix

Am Mittwoch, den 15.12.2010, 14:56 +0100 schrieb Bertrand Delacretaz: 
> Hi,
> 
> I'm playing with LogReaderService [1] with the goal of intercepting
> and selectively persisting some log messages, ideally without changing
> existing components.
> 
> Before I dig too deep: am I right that our OSGi LogService and slf4j
> logging are two separate things, with no connection between them?
> 
> I thought we had a bridge between them, but at first sight it doesn't
> seem like it: my LogListener only gets messages sent directly to the
> LogService, and nothing that's sent using slf4j interfaces.
> 
> -Bertrand
> 
> [1] http://www.osgi.org/javadoc/r4v42/org/osgi/service/log/LogReaderService.html