Pax Logging
  1. Pax Logging
  2. PAXLOGGING-138

Pax Logging - bundle.id, name and version is not displayed in logs when the bundle use java.util.logging.Logger,

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.6.7, 1.7.0
    • Component/s: None
    • Labels:
      None

      Description

      In org.ops4j.pax.logging.service.internal.JdkHandler.publish method, there's a TODO comment like
      // TODO: Can't associate a bundle with the JDK logger. So how??

      the pax-logging org.ops4j.pax.logging.service.internal.JdkHandler can't associate a bundle with the JDK logger, so any bundle which use java.util.logging.Logger, can't get bundle infos in pax-logging, that's why we can't see bundle specific info(bundle name, id, version) from log if the bundle use java.util.logging.Logger, but it's OK when use other Loggers.

        Activity

        Hide
        Freeman Fang added a comment -

        Attach a patch

        Show
        Freeman Fang added a comment - Attach a patch
        Hide
        Chris Dolan added a comment -

        Freeman,
        Just curious, why did you choose to use the SecurityManager instead of
        new Exception().getStackTrace()
        to walk the caller stack?

        Show
        Chris Dolan added a comment - Freeman, Just curious, why did you choose to use the SecurityManager instead of new Exception().getStackTrace() to walk the caller stack?
        Hide
        Freeman Fang added a comment -

        commit fix to master

        commit a06d511285bc933eec658a40ff73622373c386d5
        Author: Freeman Fang <freeman.fang@gmail.com>
        Date:   Thu May 3 20:52:12 2012 +0800
        
            [PAXLOGGING-138]Pax Logging - bundle.id, name and version is not displayed in logs when the bundle use java.util.logging.Logger
            (cherry picked from commit bc6647a6cf7154f21d42e856ac08f81991200636)
        

        to paxlogging-1.6.x branch

        commit bc6647a6cf7154f21d42e856ac08f81991200636
        Author: Freeman Fang <freeman.fang@gmail.com>
        Date:   Thu May 3 20:52:12 2012 +0800
        
            [PAXLOGGING-138]Pax Logging - bundle.id, name and version is not displayed in logs when the bundle use java.util.logging.Logger
        
        Show
        Freeman Fang added a comment - commit fix to master commit a06d511285bc933eec658a40ff73622373c386d5 Author: Freeman Fang <freeman.fang@gmail.com> Date: Thu May 3 20:52:12 2012 +0800 [PAXLOGGING-138]Pax Logging - bundle.id, name and version is not displayed in logs when the bundle use java.util.logging.Logger (cherry picked from commit bc6647a6cf7154f21d42e856ac08f81991200636) to paxlogging-1.6.x branch commit bc6647a6cf7154f21d42e856ac08f81991200636 Author: Freeman Fang <freeman.fang@gmail.com> Date: Thu May 3 20:52:12 2012 +0800 [PAXLOGGING-138]Pax Logging - bundle.id, name and version is not displayed in logs when the bundle use java.util.logging.Logger
        Hide
        Freeman Fang added a comment -

        Hi Chris,

        Both way can get the stacktrace, but from the SecurityManager we can get the stacktrace as Class[] directly, which can easily call the FrameworkUtil#getBundle(Class) to get the caller bundle.

        Regards
        Freeman

        Show
        Freeman Fang added a comment - Hi Chris, Both way can get the stacktrace, but from the SecurityManager we can get the stacktrace as Class[] directly, which can easily call the FrameworkUtil#getBundle(Class) to get the caller bundle. Regards Freeman
        Hide
        Chris Dolan added a comment -

        In master, you fixed only the code in pax-logging-service. The JdkHandler class is duplicated in pax-logging-logback, so it needs to be patched there too. Ultimately, this code duplication needs to be corrected, but in the meantime the code needs to be synchronized.

        Notably, the logback implementation already adds the bundle detail to exception stack traces via Exception.getStackTrace() and FrameworkUtil.getBundle(). But that's just for the throwable, not for the message.

        Show
        Chris Dolan added a comment - In master, you fixed only the code in pax-logging-service. The JdkHandler class is duplicated in pax-logging-logback, so it needs to be patched there too. Ultimately, this code duplication needs to be corrected, but in the meantime the code needs to be synchronized. Notably, the logback implementation already adds the bundle detail to exception stack traces via Exception.getStackTrace() and FrameworkUtil.getBundle(). But that's just for the throwable, not for the message.
        Hide
        Chris Dolan added a comment -

        OK, thanks for the SecurityManager vs. Exception explanation. I should have realized that.

        Show
        Chris Dolan added a comment - OK, thanks for the SecurityManager vs. Exception explanation. I should have realized that.
        Hide
        Freeman Fang added a comment -

        also patch JdkHandler in pax-logging-logback on master

        commit 29c27a7c23b80795404ca898290f16da9eb1c512
        Author: Freeman Fang <freeman.fang@gmail.com>
        Date:   Thu May 3 21:22:28 2012 +0800
        
            [PAXLOGGING-138]also patch JdkHandler in pax-logging-logback
        

        @Chris,
        Thanks for pointing out the pax-logging-logback on master

        Show
        Freeman Fang added a comment - also patch JdkHandler in pax-logging-logback on master commit 29c27a7c23b80795404ca898290f16da9eb1c512 Author: Freeman Fang <freeman.fang@gmail.com> Date: Thu May 3 21:22:28 2012 +0800 [PAXLOGGING-138]also patch JdkHandler in pax-logging-logback @Chris, Thanks for pointing out the pax-logging-logback on master

          People

          • Assignee:
            Freeman Fang
            Reporter:
            Freeman Fang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development