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

Details

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.

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

Freeman Fang
added a comment - 03/May/12 3:04 PM 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

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.

Chris Dolan
added a comment - 03/May/12 3:10 PM 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.