Camel MDC appender in Karaf

Nine Stars

Camel MDC appender in Karaf

Hi,

 

Does anyone know how to add Camel MDC appender in karaf with log4j2 ?

 

With log4j, it used to be:

# Camel MDC appender
log4j.appender.camel-mdc=org.apache.log4j.sift.MDCSiftingAppender
log4j.appender.camel-mdc.key=camel.routeId
log4j.appender.camel-mdc.default=unknown
log4j.appender.camel-mdc.appender=org.apache.log4j.FileAppender
log4j.appender.camel-mdc.appender.layout=org.apache.log4j.PatternLayout
log4j.appender.camel-mdc.appender.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{camel.exchangeId} | %m%n
log4j.appender.camel-mdc.appender.file=${karaf.data}/log/camel-$\\{camel.routeId\\}.log
log4j.appender.camel-mdc.appender.append=true
 
Thanks for your help.
 
Eric
Moderator

Re: Camel MDC appender in Karaf

Hello Eric,

We have redirected your issue to our ESB experts and then come back to you as soon as we can.

Thanks for your time.

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Six Stars

Re: Camel MDC appender in Karaf

I managed to make MDC work with LOG4J 2

 

log4j2.rootLogger.appenderRef.Camel.ref = Camel

log4j2.patternCamel = %d{ISO8601}|%-5.5p|%X{bundle.id}|%X{camel.routeId}|%X{bundle.name}|%m%n

log4j2.appender.camel.type = Routing
log4j2.appender.camel.name = Camel
log4j2.appender.camel.routes.type = Routes
log4j2.appender.camel.routes.pattern = $$\\{ctx:context.routeId\\}
log4j2.appender.camel.routes.context.type = Route
log4j2.appender.camel.routes.context.rolling.type = RollingFile
log4j2.appender.camel.routes.context.rolling.name = camel-$\\{ctx:context.routeId\\}
log4j2.appender.camel.routes.context.rolling.layout.type = PatternLayout
log4j2.appender.camel.routes.context.rolling.layout.pattern = ${log4j2.patternCamel}
log4j2.appender.camel.routes.context.rolling.fileName = ${karaf.data}/log/camel-$\\{ctx:context.routeId\\}.log
log4j2.appender.camel.routes.context.rolling.filePattern= ${karaf.data}/log/camel-$\\{ctx:context.routeId\\}.log.%i
log4j2.appender.camel.routes.context.rolling.policies.type = Policies
log4j2.appender.camel.routes.context.rolling.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.camel.routes.context.rolling.policies.size.size = 20MB
Six Stars

Re: Camel MDC appender in Karaf

I managed to make MDC work with LOG4J 2

 

log4j2.patternCamel = %d{ISO8601}|%-5.5p|%X{bundle.id}|%X{camel.routeId}|%X{bundle.name}|%m%n

log4j2.rootLogger.appenderRef.Camel.ref = Camel

log4j2.appender.camel.type = Routing
log4j2.appender.camel.name = Camel
log4j2.appender.camel.routes.type = Routes
log4j2.appender.camel.routes.pattern = $$\\{ctx:camel.contextId\\}
log4j2.appender.camel.routes.context.type = Route
log4j2.appender.camel.routes.context.rolling.type = RollingFile
log4j2.appender.camel.routes.context.rolling.name = camel-$\\{ctx:camel.contextId\\}
log4j2.appender.camel.routes.context.rolling.layout.type = PatternLayout
log4j2.appender.camel.routes.context.rolling.layout.pattern = ${log4j2.patternCamel}
log4j2.appender.camel.routes.context.rolling.fileName = ${karaf.data}/log/camel-$\\{ctx:camel.contextId\\}.log
log4j2.appender.camel.routes.context.rolling.filePattern= ${karaf.data}/log/camel-$\\{ctx:camel.contextId\\}.log.%i
log4j2.appender.camel.routes.context.rolling.policies.type = Policies
log4j2.appender.camel.routes.context.rolling.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.camel.routes.context.rolling.policies.size.size = 20MB