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

Xilai Dai commented on CAMEL-11352:
-----------------------------------

Claus, from my test result, the pax-logging-service bundle (support log4j 1.x) 
sent duplicated log entries sometimes, so I think that's why the doAppend() of 
PaxLoggingConsumer made multi thread/add MDC checking to avoid these situation 
from camel side. but with pax-logging-log4j2 bundle installed, I don't see 
duplicated log entries any longer from it, but the new problem is, we got a lot 
duplicated logs from camel-paxlogging side.

For example the logs from my test case above:
{code}
Apache Camel 2.19.0 (CamelContext: camel-1) started in 0.234 seconds
Apache Camel 2.19.0 (CamelContext: camel-1) started in 0.234 seconds
Apache Camel 2.19.0 (CamelContext: camel-1) started in 0.234 seconds
Started bundle: 
file:/G:/download/apache-karaf-4.1.1/deploy/test-paxlogging-camel-1.0.0.jar
{code}

the original logs from pax-logging-log4j2 are (as expected):
{code}
Route: route1 started and consuming from: Endpoint[paxlogging://mylog]
Total 1 routes, of which 1 are started.
Apache Camel 2.17.6 (CamelContext: camel-1) started in 0.234 seconds
Started bundle: 
file:/G:/download/apache-karaf-4.1.1/deploy/test-paxlogging-camel-1.0.0.jar
{code}

> duplicated/missing logs when camel-paxlogging work with pax-logging-log4j2
> --------------------------------------------------------------------------
>
>                 Key: CAMEL-11352
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11352
>             Project: Camel
>          Issue Type: Bug
>    Affects Versions: 2.17.6, 2.19.0
>            Reporter: Xilai Dai
>
> This problem is found after switch to the karaf 4.1.x, which using 
> pax-logging-log4j2 insteadof pax-logging-service.
> I created a small test case project for reproduce this issue. 
> https://github.com/xldai/test/tree/master/test-paxlogging-camel
> The findings from me is that, when PaxLoggingConsumer class [1] work together 
> with pax-logging-service (karaf 4.0.x), it creates new threads to process the 
> incoming PaxLoggingEvent and using MDC to filter the possible duplicated logs 
> from PaxAppenderProxy class [2].
> but when PaxLoggingConsumer class work together with pax-logging-log4j2, the 
> multi thread mechanism for processing the PaxLoggingEvent will lead to 
> duplicated/missing logs output to the camel Exchange.
> Since the L63 from [3] fixed the possible duplicated logs come from 
> PaxAppenderProxy class, I found that the multi thread mechanism and MDC 
> checking can be removed from PaxLoggingConsumer class, then it works again as 
> expected from my test result.
> [1] 
> https://github.com/apache/camel/blob/master/components/camel-paxlogging/src/main/java/org/apache/camel/component/paxlogging/PaxLoggingConsumer.java#L58
> [2] 
> https://github.com/ops4j/org.ops4j.pax.logging/blob/logging-1.9.1/pax-logging-service/src/main/java/org/ops4j/pax/logging/service/internal/PaxAppenderProxy.java#L63
> [3] 
> https://github.com/ops4j/org.ops4j.pax.logging/blob/logging-1.9.1/pax-logging-log4j2/src/main/java/org/ops4j/pax/logging/log4j2/internal/PaxAppenderProxy.java#L63



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to