Hi JB,

I am also interested in this functionality and I have tried the same on a
Mac. All worked good for me, but I see a file
created camel-context-${ctx:camel.contextId}.log in the data/log folder
that contains the entire duplicate log. Same as karaf.log. Have you
observed the same?

Than you,
Oleg

On Fri, Jan 22, 2021 at 12:09 AM Jean-Baptiste Onofre <j...@nanthrax.net>
wrote:

> Hi Michael,
>
> I’ve resumed my test about Camel MDC.
>
> So, I created a simple route like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";>
>
>   <camelContext xmlns="http://camel.apache.org/schema/blueprint";
> useMDCLogging="true">
>     <route id="test">
>       <from uri="timer:fire?period=5000"/>
>       <setBody><constant>Hello World</constant></setBody>
>       <to uri="log:test"/>
>     </route>
>   </camelContext>
>
> </blueprint>
>
> Then, in etc/org.ops4j.pax.logging.cfg, I added:
>
> log4j2.rootLogger.appenderRef.Sift.ref = Routing
>
> …
>
> log4j2.appender.routing.type = Routing
> log4j2.appender.routing.name = Routing
> log4j2.appender.routing.routes.type = Routes
> log4j2.appender.routing.routes.pattern = \$\$\\\{ctx:bundle.name\}
> log4j2.appender.routing.routes.bundle.type = Route
> log4j2.appender.routing.routes.bundle.appender.type
> = RollingRandomAccessFile
> log4j2.appender.routing.routes.bundle.appender.name = Bundle-\$\\\{ctx:
> bundle.name\}
> log4j2.appender.routing.routes.bundle.appender.fileName
> = ${karaf.log}/camel-context-\$\\\{ctx:camel.contextId\}.log
> log4j2.appender.routing.routes.bundle.appender.filePattern
> = ${karaf.log}/bundle-\$\\\{ctx:bundle.name\}.log.%i
> log4j2.appender.routing.routes.bundle.appender.append = true
> log4j2.appender.routing.routes.bundle.appender.layout.type = PatternLayout
> log4j2.appender.routing.routes.bundle.appender.layout.pattern
> = ${log4j2.pattern}
> log4j2.appender.routing.routes.bundle.appender.policies.type = Policies
> log4j2.appender.routing.routes.bundle.appender.policies.size.type
> = SizeBasedTriggeringPolicy
> log4j2.appender.routing.routes.bundle.appender.policies.size.size = 8MB
>
> You can see the fileName containing camel.contextId.
>
> In data/log, I can see the log file created for my Camel
> Context: camel-context-camel-1.log containing:
>
> 2021-01-22T06:07:28,801 | INFO  | Blueprint Event Dispatcher: 1 |
> JmxManagementStrategy            | 88 - org.apache.camel.camel-management -
> 3.7.0 | JMX is enabled
> 2021-01-22T06:07:28,890 | INFO  | Blueprint Event Dispatcher: 1 |
> AbstractCamelContext             | 65 - org.apache.camel.camel-base-engine
> - 3.7.0 | Apache Camel 3.7.0 (camel-1) is starting
> 2021-01-22T06:07:28,892 | INFO  | Blueprint Event Dispatcher: 1 |
> AbstractCamelContext             | 65 - org.apache.camel.camel-base-engine
> - 3.7.0 | MDC logging is enabled on CamelContext: camel-1
> 2021-01-22T06:07:28,968 | INFO  | Blueprint Event Dispatcher: 1 |
> AbstractCamelContext             | 65 - org.apache.camel.camel-base-engine
> - 3.7.0 | StreamCaching is not in use. If using streams then it's
> recommended to enable stream caching. See more details at
> http://camel.apache.org/stream-caching.html
> 2021-01-22T06:07:28,998 | INFO  | Blueprint Event Dispatcher: 1 |
> InternalRouteStartupManager      | 65 - org.apache.camel.camel-base-engine
> - 3.7.0 | Route: test started and consuming from: timer://fire
> 2021-01-22T06:07:29,003 | INFO  | Blueprint Event Dispatcher: 1 |
> AbstractCamelContext             | 65 - org.apache.camel.camel-base-engine
> - 3.7.0 | Total 1 routes, of which 1 are started
> 2021-01-22T06:07:29,004 | INFO  | Blueprint Event Dispatcher: 1 |
> AbstractCamelContext             | 65 - org.apache.camel.camel-base-engine
> - 3.7.0 | Apache Camel 3.7.0 (camel-1) started in 112ms
> 2021-01-22T06:07:30,017 | INFO  | Camel (camel-1) thread #1 - timer://fire
> | test                             | 63 - org.apache.camel.camel-api -
> 3.7.0 | Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello
> World]
>
> So, all good.
>
> Can you confirm that if you use this on your machine it doesn’t work ?
>
> I’m looking for a Windows VM to test.
>
> Regards
> JB
>
> Le 21 janv. 2021 à 10:31, michael e <michaelel...@outlook.fr> a écrit :
>
> Hello JB,
>
> Any news or fix ?
>
> Thanks regards,
> Michael.
>
> ------------------------------
> *De :* Jean-Baptiste Onofre <j...@nanthrax.net>
> *Envoyé :* jeudi 14 janvier 2021 10:16
> *À :* user <user@karaf.apache.org>
> *Objet :* Re: Configuring MDC logging karaf 4 camel 3.7.0
>
> Oh my bad, I completely forget the Windows test ;)
>
> I will do it just after AMQ release. For the tracking I will create a Jira.
>
> I’m very sorry.
>
> Regards
> JB
>
> Le 14 janv. 2021 à 10:03, michael e <michaelel...@outlook.fr> a écrit :
>
> Hi JB,
>
> Any news about this ?
>
> Regards,
> Michael.
>
> ------------------------------
>
> *De :* Jean-Baptiste Onofre <j...@nanthrax.net>
> *Envoyé :* mercredi 6 janvier 2021 17:21
> *À :* user@karaf.apache.org <user@karaf.apache.org>
> *Objet :* Re: Configuring MDC logging karaf 4 camel 3.7.0
>
> Hi Michael,
>
> Happy new year too !
>
> I forgot during end of year vacation. I’m busy with ActiveMQ release
> preparation now, but I will switch back to test on Windows tomorrow.
>
> Regards
> JB
>
> Le 6 janv. 2021 à 17:07, michael e <michaelel...@outlook.fr> a écrit :
>
> Hello JB,
>
> Happy new year, any news about this ?
>
> Thanks,
> Michael.
>
> ------------------------------
>
> *De :* JB Onofré <j...@nanthrax.net>
> *Envoyé :* jeudi 24 décembre 2020 17:00
> *À :* user@karaf.apache.org <user@karaf.apache.org>
> *Objet :* Re: Configuring MDC logging karaf 4 camel 3.7.0
>
> I would consider as a big if I have the error on Windows.
>
> I’m suspecting an issue on Windows only (I hate this os ;) ).
>
> Let me setup a vm (just need time).
>
> Regard
> JB
>
> Le 24 déc. 2020 à 16:36, michael e <michaelel...@outlook.fr> a écrit :
>
> 
> Ok thanks so is a bug ? Or i just have to change something ? (This is the
> provided configuration i didn't change anythin expect fileName pattern)
>
> Regards,
> Michael.
>
> ------------------------------
>
> *De :* JB Onofré <j...@nanthrax.net>
> *Envoyé :* jeudi 24 décembre 2020 16:23
> *À :* user@karaf.apache.org <user@karaf.apache.org>
> *Objet :* Re: Configuring MDC logging karaf 4 camel 3.7.0
>
> Understood. I don’t have any error. The error you have seems related to
> the rolling file configuration.
>
> Regards
> JB
>
> Le 24 déc. 2020 à 15:16, michael e <michaelel...@outlook.fr> a écrit :
>
> 
> Ok thanks  'All log files are created and populated' for me also just
> then in the karaf i see ERROR logs
>
> Thanks,
> Regards,
> Michael.
>
> ------------------------------
>
> *De :* JB Onofré <j...@nanthrax.net>
> *Envoyé :* jeudi 24 décembre 2020 15:05
> *À :* user@karaf.apache.org <user@karaf.apache.org>
> *Objet :* Re: Configuring MDC logging karaf 4 camel 3.7.0
>
> Yeah. I tried with the karaf camel examples. All log files are created and
> populated.
>
> I will bootstrap a Windows vm to test.
>
> Regards
> JB
>
> Le 24 déc. 2020 à 14:52, michael e <michaelel...@outlook.fr> a écrit :
>
> 
> No it is a last fresh download version ok Karaf (4.3.0) did you try with
> camel MDC properties ? And no permission issues.
>
> Michael.
>
> ------------------------------
>
> *De :* JB Onofré <j...@nanthrax.net>
> *Envoyé :* jeudi 24 décembre 2020 14:42
> *À :* user@karaf.apache.org <user@karaf.apache.org>
> *Objet :* Re: Configuring MDC logging karaf 4 camel 3.7.0
>
> By the way, you don’t have any permission issue ?
>
> Le 24 déc. 2020 à 14:42, JB Onofré <j...@nanthrax.net> a écrit :
>
> 
> Do you use karaf vanilla or a custom distribution ?
>
> I confirm that it works fine for me on Karaf vanilla (at least on Linux).
>
> Regards
> JB
>
> Le 24 déc. 2020 à 14:02, michael e <michaelel...@outlook.fr> a écrit :
>
> 
> I also add the absolute path i also get exception
>
> my configuration:
>
> # Sift - MDC routing
> log4j2.appender.routing.type = Routing
> log4j2.appender.routing.name = Routing
> log4j2.appender.routing.routes.type = Routes
> log4j2.appender.routing.routes.pattern = \$\$\\\{ctx:bundle.name\}
> log4j2.appender.routing.routes.bundle.type = Route
> log4j2.appender.routing.routes.bundle.appender.type =
> RollingRandomAccessFile
> log4j2.appender.routing.routes.bundle.appender.name = Bundle-\$\\\{ctx:
> bundle.name\}
> log4j2.appender.routing.routes.bundle.appender.fileName =
> D:/karaf/apache-karaf-4.3.0/data/log/bundle-*\$\\\{ctx:camel.contextId\}.*
> log
> log4j2.appender.routing.routes.bundle.appender.filePattern =
> ${karaf.log}/bundle-\$\\\{ctx:bundle.name\}.log.%i
> log4j2.appender.routing.routes.bundle.appender.append = true
> log4j2.appender.routing.routes.bundle.appender.layout.type = PatternLayout
> log4j2.appender.routing.routes.bundle.appender.layout.pattern =
> ${log4j2.pattern}
> log4j2.appender.routing.routes.bundle.appender.policies.type = Policies
> log4j2.appender.routing.routes.bundle.appender.policies.size.type =
> SizeBasedTriggeringPolicy
> log4j2.appender.routing.routes.bundle.appender.policies.size.size = 8MB
>
> Exception:
>
> org.ops4j.pax.logging.pax-logging-log4j2 [log4j2] ERROR : Cannot access
> RandomAccessFile java.io.IOException: La syntaxe du nom de fichier, de
> répertoire ou de volume est incorrecte
> org.ops4j.pax.logging.pax-logging-log4j2 [log4j2] ERROR : Could not create
> plugin of type class
> org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for
> element RollingRandomAccessFile: java.lang.IllegalStateException:
> ManagerFactory
> [org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$RollingRandomAccessFileManagerFactory@7ab1ab29]
> unable to create manager for
> [D:/karaf/apache-karaf-4.3.0/data/log/bundle-${ctx:camel.contextId}.log]
> with data
> [org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$FactoryData@3219c6e6
> ]
> org.ops4j.pax.logging.pax-logging-log4j2 [log4j2] ERROR : Unable to invoke
> factory method in class
> org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for
> element RollingRandomAccessFile: java.lang.IllegalStateException: No
> factory method found for class
> org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender
> org.ops4j.pax.logging.pax-logging-log4j2 [log4j2] ERROR : Unable to create
> Appender of type RollingRandomAccessFile
>
> Regards,
> Michael.
>
> ------------------------------
>
> *De :* Jean-Baptiste Onofre <j...@nanthrax.net>
> *Envoyé :* jeudi 24 décembre 2020 07:13
> *À :* user@karaf.apache.org <user@karaf.apache.org>
> *Objet :* Re: Configuring MDC logging karaf 4 camel 3.7.0
>
> Hi,
>
> I just tested the configuration I provided in
> etc/org.ops4j.pax.logging.cfg.
>
> Here’s my config (in etc/org.ops4j.pax.logging.cfg):
>
> First, I’ve enabled sift appender:
>
> log4j2.rootLogger.appenderRef.Sift.ref = Routing
>
> Then, I added the appender:
>
> log4j2.appender.routing.type = Routing
> log4j2.appender.routing.name = Routing
> log4j2.appender.routing.routes.type = Routes
> log4j2.appender.routing.routes.pattern = \$\$\\\{ctx:bundle.name\}
> log4j2.appender.routing.routes.bundle.type = Route
> log4j2.appender.routing.routes.bundle.appender.type
> = RollingRandomAccessFile
> log4j2.appender.routing.routes.bundle.appender.name = Bundle-\$\\\{ctx:
> bundle.name\}
> log4j2.appender.routing.routes.bundle.appender.fileName
> = ${karaf.log}/bundle-\$\\\{ctx:bundle.name\}.log
> log4j2.appender.routing.routes.bundle.appender.filePattern
> = ${karaf.log}/bundle-\$\\\{ctx:bundle.name\}.log.%i
> log4j2.appender.routing.routes.bundle.appender.append = true
> log4j2.appender.routing.routes.bundle.appender.layout.type = PatternLayout
> log4j2.appender.routing.routes.bundle.appender.layout.pattern
> = ${log4j2.pattern}
> log4j2.appender.routing.routes.bundle.appender.policies.type = Policies
> log4j2.appender.routing.routes.bundle.appender.policies.size.type
> = SizeBasedTriggeringPolicy
> log4j2.appender.routing.routes.bundle.appender.policies.size.size = 8MB
>
> And it works fine.
>
> It seems that your problem is about Windows.
> You are mixing windows style path with Unix style.
>
> For fileName and filePattern, can you please use absolution path.
> Something like:
>
> log4j2.appender.routing.routes.bundle.appender.fileName =
>  D:\karaf\apache-karaf-4.3.0\bundle-\$\\\{ctx:bundle.name\}.log
>
> It should work.
>
> Regards
> JB
>
> Le 23 déc. 2020 à 10:58, michael e <michaelel...@outlook.fr> a écrit :
>
> Hello,
>
> I'm getting in trouble trying to configure MDC logging with latest Karaf
> and Camel Version
>
> Here my logging configuration
>
> log4j2.appender.routing.type = Routing
> log4j2.appender.routing.name = Routing
> log4j2.appender.routing.routes.type = Routes
> log4j2.appender.routing.routes.pattern = \$\$\\\{ctx:bundle.name\}
> log4j2.appender.routing.routes.bundle.type = Route
> log4j2.appender.routing.routes.bundle.appender.type =
> RollingRandomAccessFile
> log4j2.appender.routing.routes.bundle.appender.name = Bundle-\$\\\{ctx:
> bundle.name\}
> log4j2.appender.routing.routes.bundle.appender.fileName =
> ${karaf.data}/log/sift-camel-\$\\\{ctx:camel.contextId\}.log
> log4j2.appender.routing.routes.bundle.appender.filePattern =
> ${karaf.log}/bundle-\$\\\{ctx:bundle.name\}.log.%i
> log4j2.appender.routing.routes.bundle.appender.append = true
> log4j2.appender.routing.routes.bundle.appender.layout.type = PatternLayout
> log4j2.appender.routing.routes.bundle.appender.layout.pattern =
> ${log4j2.pattern}
> log4j2.appender.routing.routes.bundle.appender.policies.type = Policies
> log4j2.appender.routing.routes.bundle.appender.policies.size.type =
> SizeBasedTriggeringPolicy
> log4j2.appender.routing.routes.bundle.appender.policies.size.size = 8MB
>
> Logging file is correctly created but i get exception in my Karaf
>
>
> karaf@root()> org.ops4j.pax.logging.pax-logging-log4j2 [log4j2] ERROR :
> Cannot access RandomAccessFile java.io.IOException: La syntaxe du nom de
> fichier, de répertoire ou de volume est incorrecte
> org.ops4j.pax.logging.pax-logging-log4j2 [log4j2] ERROR : Could not create
> plugin of type class
> org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for
> element RollingRandomAccessFile: java.lang.IllegalStateException:
> ManagerFactory
> [org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$RollingRandomAccessFileManagerFactory@26d9daed]
> unable to create manager for
> [D:\karaf\apache-karaf-4.3.0\data/log/sift-camel-${ctx:camel.contextId}.log]
> with data
> [org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$FactoryData@34bd66be
> ]
> org.ops4j.pax.logging.pax-logging-log4j2 [log4j2] ERROR : Unable to invoke
> factory method in class
> org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for
> element RollingRandomAccessFile: java.lang.IllegalStateException: No
> factory method found for class
> org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender
> org.ops4j.pax.logging.pax-logging-log4j2 [log4j2] ERROR : Unable to create
> Appender of type RollingRandomAccessFile
> org.ops4j.pax.logging.pax-logging-log4j2 [log4j2] ERROR : Cannot access
> RandomAccessFile java.io.IOException: La syntaxe du nom de fichier, de
> répertoire ou de volume est incorrecte
> org.ops4j.pax.logging.pax-logging-log4j2 [log4j2] ERROR : Could not create
> plugin of type class
> org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for
> element RollingRandomAccessFile: java.lang.IllegalStateException:
> ManagerFactory
> [org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$RollingRandomAccessFileManagerFactory@26d9daed]
> unable to create manager for
> [D:\karaf\apache-karaf-4.3.0\data/log/sift-camel-${ctx:camel.contextId}.log]
> with data
> [org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$FactoryData@19f28b4
> ]
> org.ops4j.pax.logging.pax-logging-log4j2 [log4j2] ERROR : Unable to invoke
> factory method in class
> org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for
> element RollingRandomAccessFile: java.lang.IllegalStateException: No
> factory method found for class
> org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender
> org.ops4j.pax.logging.pax-logging-log4j2 [log4j2] ERROR : Unable to create
> Appender of type RollingRandomAccessFile
>
> There is updated documentation about how to configure ?
>
> Michael.
>
>
>

-- 
*Oleg Cohen  |  Principal  |  **A S S U R E B R I D G E*
*Office: +1 617 564 0737  |  Mobile: +1 617 455 7927  |  Fax: +1 888 409
6995*
*Email: oleg.co...@assurebridge.com <oleg.co...@assurebridge.com>  **|
 www.assurebridge.com <http://www.assurebridge.com>*

Reply via email to