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@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@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user