3 Replies Latest reply on Feb 5, 2012 7:36 PM by Willem Jiang

    pax logging and slf4j

    Timothy Stewart Newbie

      This should hopefully be a simple enough question for someone with some deeper knowledge of the platform than I have.


      I have created a number of bundles, each adds a dependency on slf4j-api.jar in the pom, and bnd creates an import for the package.  I deploy my bundle, but not the slf4j-api.jar, since it is my understanding that the pax logging includes this api.


      It all worked fine, and my bundles are logging to the main ESB log files.


      The trouble came when I tried to use the Profiler class, which is in the slf4j-ext.jar.  Upon deploying my bundle, I had an unresolved dependency on the ext package.  I deployed the slf4j-ext.jar downloaded from slf4j.org, which conveniently is an OSGi bundle.


      That bundle wouldn't resolve based on the following message:



      org.osgi.framework.BundleException: Unresolved constraint in bundle slf4j.api : Unable to resolve 372.0: missing requirement package; (&(package=


              at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3455)

              at org.apache.felix.framework.Felix.startBundle(Felix.java:1728)



      I thought that pax logging must already have an org.slf4j.impl package, but perhaps I'm misunderstanding.  Maybe it does, but does not export it.


      At this point, I'm not sure if I should deploy one of the slf4j implementation packages, and if so which one.  I still want my logging to go through pax, so I don't inadvertently want to redirect it through some other framework.


      Thanks for any advice.


      - Tim Stewart.

        • 1. Re: pax logging and slf4j
          Willem Jiang Master



          I just checked the code of pax logging, it doesn't export the org.slf4j.impl package in the pax-logging-api as pax-logging is not want to expose the implementation of the other logging system. To achieve this pax-logging did some customization on the impl class to let is leverage the pax-logging-services which is based on log4j.


          So I doubt you can use slf4j-ext.jar out of box in servicemix even you deploy it as an OSGi bundle.


          If you still want to implement this kind of feature, you may need to buy some commercial support or do it yourself.



          • 2. Re: pax logging and slf4j
            Timothy Stewart Newbie

            This turned out to be an issue of versions.  I was using the latest versions of slf4j-ext.jar, and trying to deploy it, but the FUSE components were searching for a specific version.


            Once I deployed the right version, everything came together.

            • 3. Re: pax logging and slf4j
              Willem Jiang Master

              I checked the code of the Profile.class. It doesn't have any dependency of org.slf4j.impl.*. But I don't know if your slf4j-ext.jar needs to import the package of org.slf4j.impl ?