How to set the logger (log name / log name) in Camel's onException clause?
I have the following route:
onException(Exception.class)
.logExhausted(true)
.logStackTrace(true)
.logExhaustedMessageHistory(true)
.process(new MyErrorProcessor());
from(uri)
.process(new MyProcessor());
When an error occurs, the logs are printed in the log category org.apache.camel.processor.DefaultErrorHandler. Is there a way to change this to its own log category? .ErrorHandler () allows you to set the log category, but .onException () doesn't seem to allow that.
Thank.
+3
source to share
2 answers
You can try something like this:
onException(Exception.class)
.handled(true)
.log(LoggingLevel.ERROR, this.getClass().getSimpleName(),
"${exception.stacktrace} ${messageHistory(false)}");
You can also look at other variables here: https://camel.apache.org/manual/latest/simple-language.html
0
source to share