4 Replies Latest reply on Jan 21, 2011 9:57 AM by gmdavidson62

    pax logging question

    gmdavidson62

      I have been trying to get my "application" bundle deployed in FUSE 4.3 to log to it's own file.

       

      My code:

      private static final Logger LOGGER = Logger.getLogger(WSService.class);

      public Object execute(Object part) {

      LOGGER.debug("Object type: "part.getClass().getName());+

      }

       

      My OSGI import:

      <Import-Package>

      ........

      org.apache.log4j;version="1.2.9";provider=paxlogging;mandatory:=provider

      </Import-Package>

       

      This file (org.ops4j.pax.logging.cfg) seems to be configured correctly:

      Sift appender

      log4j.appender.sift=org.apache.log4j.sift.MDCSiftingAppender

      log4j.appender.sift.key=bundle.name

      log4j.appender.sift.default=servicemix

      log4j.appender.sift.appender=org.apache.log4j.FileAppender

      log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout

      log4j.appender.sift.appender.layout.ConversionPattern=%d | %-5.5p | %-16.16t | %-32.32c | %-32.32C %4L | %m%n

      log4j.appender.sift.appender.file=${karaf.data}/log/$
      {bundle.name
      }.log

      log4j.appender.sift.appender.append=true

       

       

      I have looked through the forum.  I have looked at all the links in the forum, including:

      http://fusesource.com/forums/thread.jspa?messageID=8547&#8547

      http://servicemix.396122.n5.nabble.com/OSGI-Bundle-log4j-td421030.html

       

      I know I must be missing something simple, but for whatever reason, my bundle's in not logging, at least I can't find it.

      Any help would be greatly appreciated.

        • 1. Re: pax logging question
          gmdavidson62

          Any answers or things to try....please???

           

          Thanks!

          • 2. Re: pax logging question
            ffang

            Hi,

             

            Did you already actually use sift appender?

             

            You need change default

            log4j.rootLogger=INFO, out, osgi:VmLogAppender

            to

            log4j.rootLogger=INFO, sift, osgi:VmLogAppender

             

            which will make log output file per bundle take effect.

             

            Freeman

            • 3. Re: pax logging question
              gmdavidson62

              Thank you for the response.  This did get the bundle logging implemented/working. 

              However, my "test" bundle is still not logging.

               

              This is from my pom:

              <Import-Package>

              .........

              org.apache.log4j;version="1.2.9";provider=paxlogging;mandatory:=provider

              </Import-Package>

               

              I'm sure I'm missing something very simple.

               

              Basically, I just want to have my bundle log to it's own log file, it doesn't matter how.

               

              Thanks!

              • 4. Re: pax logging question
                gmdavidson62

                Thanks for the answer, this did what I wanted.  I had a typo...corrected that and now the logging per bundle is working.  Thanks!!