[logback-user] SLF4J in OSGi ?
Christopher BROWN
brown at reflexe.fr
Sat Jun 29 10:41:29 CEST 2013
Hi,
Wé use SLF4J and the LogService with OSGi. We provide an implementation of
LogService that uses SLF4J to perform logging, instead of using any other
implementation (which keeps things consistent).
I find the MDC (Mapped Diagnostic Context) to be very helpful for
distinguishing log messages relating to specific transactions, a big win
over the basic LogService (which benefits from MDC too in this scenario).
Specifically:
- we use an embedded instance of Apache Felix
- the host application uses native file watching to handle bundle updates
and detect runtime configuration changes... And configures logging
- therefore, SLF4J is NOT deployed as a bundle, because we want to log the
host application's activity before the framework starts.
- the host application exports the SLF4J packages, but NOT Logback, it's
the host application that binds LogBack and SLF4J, so that applications do
not see the implementation.
- we configure SLF4J programmatically, using our own configuration in the
host application (avoids headaches finding the configuration in the
classpath for OSGi bundles).
- the only disadvantage being the inability to update SLF4J / Logback
without an application restart, but it's outweighed by not having any
period without a logger available.
For implementing the LogService with SLF4J, look into LocationAwareLogger.
Implement it in the host application and register it as a service from the
framework's BundleContext. Also, export SLF4J (but not logback) using the
"system packages extra" property.
That way, you can mix SLF4J and LogService without any inconsistency.
Hope that helps.
Le 29 juin 2013 03:54, "John Shooab" <jshooab at gmail.com> a écrit :
> Hi,
>
> In our company we develop OSGi based applications and use LogService to
> logging. We use a Log Reader service that writes the logging of all bundles
> to a group of files.
>
> But there are some coworkers that vote to use SLF4J and Logback in a new
> application because it has a interface with more intuitive methods. but I'm
> reluctant. I don't see with good yes the use of the static factory method
> in OSGi.
>
> I would appreciate if anyone using Logback on OSGi share any experience
> and point any advantage of its use instead of the LogService.
>
> thanks a lot,
>
> John
> ______________________________**_________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/**listinfo/logback-user<http://mailman.qos.ch/mailman/listinfo/logback-user>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20130629/e5fe1c56/attachment-0001.html>
More information about the Logback-user
mailing list