4

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 org.apache.camel.processor.DefaultErrorHandler log category. Is there a way to change this to a custom log category? .errorHandler() allows you to set a log category but .onException() doesn't seem to allow it.

Thanks.

Nazaret K.
  • 3,409
  • 6
  • 22
  • 31

3 Answers3

0

You can try

.onException(Exception.class)
            .to("log:logger_name?level=ERROR&multiline=true&showCaughtException=true&showStackTrace=true")
...
Sergey
  • 1,332
  • 2
  • 18
  • 30
  • That's not what I really want. I need all the logging that onException's default errorHandler performs to go to my logger. Meaning, the logs for retries, retry exhausted, message history, etc. The same way that it is done with errorHandler. – Nazaret K. Oct 15 '14 at 11:06
0

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 up for more variables here: https://camel.apache.org/manual/latest/simple-language.html

error1009
  • 151
  • 2
  • 9
0

By default, the route ID is used as the logger category. Therefore, set the route ID to class name, and you can then configure logging in the usual way:

from(uri)
    .id(this.getClass().getName())
    .process(new MyProcessor());

(id may have been named routeId in Camel 2; the above works for Camel 3).

Jimothy
  • 9,150
  • 5
  • 30
  • 33