4

我有以下路线:

            onException(Exception.class)
                .logExhausted(true)
                .logStackTrace(true)
                .logExhaustedMessageHistory(true)
                .process(new MyErrorProcessor());

            from(uri)
            .process(new MyProcessor());

发生错误时,日志将打印在 org.apache.camel.processor.DefaultErrorHandler 日志类别中。有没有办法将其更改为自定义日志类别?.errorHandler() 允许您设置日志类别,但 .onException() 似乎不允许。

谢谢。

4

3 回答 3

0

你可以试试

.onException(Exception.class)
            .to("log:logger_name?level=ERROR&multiline=true&showCaughtException=true&showStackTrace=true")
...
于 2014-10-15T08:52:17.937 回答
0

你可以尝试这样的事情:

onException(Exception.class)
                .handled(true)
                .log(LoggingLevel.ERROR, this.getClass().getSimpleName(),
                        "${exception.stacktrace} ${messageHistory(false)}");

您还可以在此处查找更多变量: https ://camel.apache.org/manual/latest/simple-language.html

于 2019-10-18T09:31:48.157 回答
0

默认情况下,路由 ID 用作记录器类别。因此,将路由 ID 设置为类名,然后您可以按照通常的方式配置日志记录:

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

id可能已routeId在 Camel 2 中命名;上述适用于 Camel 3)。

于 2020-02-17T02:36:51.923 回答