Uploaded image for project: 'SLF4J'
  1. SLF4J
  2. SLF4J-243

BundleActivator would be useful

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • None
    • 1.6.x
    • jul-to-slf4j
    • None
    • Operating System: All
      Platform: All

    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

      { SLF4JBridgeHandler.install(); }

      @Override
      public void stop(BundleContext arg0) throws Exception

      { // TODO Auto-generated method stub }

      }
      ++++++ 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
      ...

      Attachments

        Activity

          People

            slf4j-dev SLF4J developers list
            sandro.aloisio@lmco.com sandro.aloisio
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: