<p dir="ltr">Hi,</p>
<p dir="ltr">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).</p>
<p dir="ltr">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).</p>
<p dir="ltr">Specifically:<br>
- we use an embedded instance of Apache Felix<br>
- the host application uses native file watching to handle bundle updates and detect runtime configuration changes... And configures logging<br>
- therefore, SLF4J is NOT deployed as a bundle, because we want to log the host application's activity before the framework starts.<br>
- 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.<br>
- we configure SLF4J programmatically, using our own configuration in the host application (avoids headaches finding the configuration in the classpath for OSGi bundles).<br>
- 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.</p>
<p dir="ltr">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.</p>
<p dir="ltr">That way, you can mix SLF4J and LogService without any inconsistency.</p>
<p dir="ltr">Hope that helps.<br></p>
<div class="gmail_quote">Le 29 juin 2013 03:54, "John Shooab" <<a href="mailto:jshooab@gmail.com">jshooab@gmail.com</a>> a écrit :<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
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.<br>
<br>
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.<br>
<br>
I would appreciate if anyone using Logback on OSGi share any experience and point any advantage of its use instead of the LogService.<br>
<br>
thanks a lot,<br>
<br>
John<br>
______________________________<u></u>_________________<br>
Logback-user mailing list<br>
<a href="mailto:Logback-user@qos.ch" target="_blank">Logback-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/logback-user" target="_blank">http://mailman.qos.ch/mailman/<u></u>listinfo/logback-user</a><br>
</blockquote></div>