One Star

Updating the camelContext within a route

Hi all,
I am looking to update the camelContext within the cConfig component of my route. I want to define the routeID which can then be used as the key in an MDC sifting appender so that I can achieve application-level logging (i.e. I want all of the log messages for this single route to be placed into their own log file).
I have: camelContext.setUseMDCLogging(true);, but I don't see a method to update the routeId of the camel context - can anyone help with this?
Thanks,
Sam
4 REPLIES
One Star

Re: Updating the camelContext within a route

routeId generated as _ (for 6.1): routeId("SimpleRecipientList_cCXF_1")
One Star

Re: Updating the camelContext within a route

Hi,
Thank you for the response. The problem I am having is that the routeId is not being picked up by my MDCSiftingAppender - the routeId is returned empty, meaning all the logs are being placed in the default file 'unknown_cc' (log4j configuration below - I have treid this with both routeId and camel.routeId)
# Camel MDC appender
log4j.appender.camel-mdc=org.apache.log4j.sift.MDCSiftingAppender
log4j.appender.camel-mdc.key=routeId
log4j.appender.camel-mdc.default=unknown_cc
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} | %X{camel.contextId} | %X{camel.routeId} | %m%n
log4j.appender.camel-mdc.appender.file=${karaf.home}/log/camel-$\\{routeId\\}.log
log4j.appender.camel-mdc.appender.append=true
Any ideas why the routeId is not being populated?
Thanks,
Sam
One Star

Re: Updating the camelContext within a route

Hi,
I have the same issue... All my logs have "unknown" instead of the route ID.
I added a cConfig component in the route with "camelContext.setUseMDCLogging(true);"
But it doesn't help.
Any idea ?
Eric
One Star

Re: Updating the camelContext within a route

In fact, if I stop and restart Karaf, it works... But if I undeploy the route and deploy it again, I get the same issue again (unknown instead of routeID in the logs). 
This issue happens in 6.1. in 6.2 it works fine...
Eric