Details
-
Improvement
-
Resolution: Unresolved
-
None
-
1.6.x
-
None
-
Operating System: All
Platform: All
-
enhancement
-
P1
-
252
Description
The jul-to-slf4j library is already OSGi compatible. However, in order for any jul invocations in the application to reach slf4j, we need to we call SLF4JBridgeHandler.install() somewhere in our application. Since this needs to be done for any OSGi application using the jul-to-slf4j bundle, it would make sense to have a BundleActivator in the jul-to-slf4j bundle itself for this purpose. This would guarantee that the SLF4JBridgeHandler is installed as soon as the jul-to-slf4j bundle is activated within the OSGi container. I've tested locally with this very simple implementation and it gets the job done just fine:
++++++ BEGIN ++++++
package org.slf4j.osgi;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.slf4j.bridge.SLF4JBridgeHandler;
public class Activator implements BundleActivator {
@Override
public void start(BundleContext bundleContext) throws Exception
@Override
public void stop(BundleContext arg0) throws Exception
}
++++++ END ++++++
This update will also require modifying the MANIFEST.MF:
...
Bundle-Activator: org.slf4j.osgi.Activator
Import-Package: org.slf4j;version=1.6.4,org.slf4j.spi;version=1.6.4, org.osgi.framework
...