[ 
https://issues.apache.org/jira/browse/CAMEL-6694?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13955364#comment-13955364
 ] 

Grzegorz Grzybek commented on CAMEL-6694:
-----------------------------------------

Hmm. The problem is in this code of 
{{org.ops4j.pax.logging.internal.BundleHelper.getCallerBundle(Bundle)}}:
{code:java}
            Class[] classCtx = securityManager.getClassContext();
            /* Skip first 2 classes on call stack since:
             *  classCtx[0] is always SecurityManagerEx.getClassContext()
             *  classCtx[1] is always BundleHelper.getCallerBundle()
             */
            Bundle curBundle = null;
            for (int i = 2; i < classCtx.length; i++)
            {
                Bundle bundle = FrameworkUtil.getBundle(classCtx[i]);
                if (bundle == null)
                {
                    return defaultBundle;
                }
                else if (curBundle == null)
                {
                    curBundle = bundle;
                }
                else if (bundle != curBundle)
                {
                    return bundle;
                }
            }
{code}

which return first bundle, which is not 
{{org.ops4j.pax.logging.pax-logging-api}} by examining the stack trace.

In the following stack trace:
{noformat}
class org.ops4j.pax.logging.internal.BundleHelper$SecurityManagerEx
class org.ops4j.pax.logging.internal.BundleHelper
class org.ops4j.pax.logging.OSGIPaxLoggingManager
class org.ops4j.pax.logging.slf4j.Slf4jLoggerFactory
class org.slf4j.LoggerFactory
class org.apache.camel.util.CamelLogger
class org.apache.camel.component.log.LogComponent
class org.apache.camel.impl.DefaultComponent
class org.apache.camel.impl.DefaultCamelContext
class org.apache.camel.impl.DefaultProducerTemplate
class org.apache.camel.impl.DefaultProducerTemplate
class org.apache.camel.itest.osgi.core.log.LogRouteTest
class org.junit.runners.model.FrameworkMethod$1
...
{noformat}

the method returns bundle for class {{org.apache.camel.util.CamelLogger}}, and 
ideally it should return bundle for 
{{org.apache.camel.itest.osgi.core.log.LogRouteTest}} which sends the message...

I'll check if I can introduce some hacks into {{CamelLogger}}.

> Make Log component and EIP compatible with log4j MDC Sift Appender
> ------------------------------------------------------------------
>
>                 Key: CAMEL-6694
>                 URL: https://issues.apache.org/jira/browse/CAMEL-6694
>             Project: Camel
>          Issue Type: Bug
>    Affects Versions: 2.12.0
>            Reporter: Raúl Kripalani
>            Assignee: Grzegorz Grzybek
>             Fix For: 2.13.1
>
>
> Refer to 
> http://camel.465427.n5.nabble.com/Logging-into-the-bundle-log-file-via-to-log-tp5738205p5738413.html
>  for more info.
> We should use the Camel Context's Classloader to initialize the Logger 
> instance.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to