You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Laurent Chabot (Jira)" <ji...@apache.org> on 2020/05/02 15:19:00 UTC
[jira] [Commented] (CAMEL-14999) Camel 3 log showCaughtException is
not working
[ https://issues.apache.org/jira/browse/CAMEL-14999?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17097994#comment-17097994 ]
Laurent Chabot commented on CAMEL-14999:
----------------------------------------
This part of the logic of {{LogComponent}} seems flawed somehow:
{code:java}
// first, try to pick up the ExchangeFormatter from the registry
ExchangeFormatter logFormatter = getCamelContext().getRegistry().lookupByNameAndType("logFormatter", ExchangeFormatter.class);
if (logFormatter != null) {
setProperties(logFormatter, parameters);
} else if (exchangeFormatter != null) {
// do not set properties, the exchangeFormatter is explicitly set, therefore the
// user would have set its properties explicitly too
logFormatter = exchangeFormatter;
}
{code}
If I explicitly bind a {{DefaultExchangeFormatter}} instance named {{logFormatter}} in the registry, then the {{if}} condition is met, {{setProperties}} is called, and things work as expected.
But this shouldn't be needed, right? Why isn't this the default behavior?
> Camel 3 log showCaughtException is not working
> ----------------------------------------------
>
> Key: CAMEL-14999
> URL: https://issues.apache.org/jira/browse/CAMEL-14999
> Project: Camel
> Issue Type: Bug
> Affects Versions: 3.0.0, 3.1.0, 3.2.0
> Reporter: Laurent Chabot
> Priority: Major
>
> Take this simple case:
> {code:java}
> CamelContext ctx = new DefaultCamelContext();
> ctx.addRoutes(new RouteBuilder() {
> @Override
> public void configure() throws Exception {
> from("direct:input")
> .doTry()
> .throwException(new Exception("Something wrong"))
> .doCatch(Exception.class)
> .end()
> .to("log:error?level=WARN&showCaughtException=true");
> }
> });
> ctx.start();
> ctx.createProducerTemplate().sendBody("direct:input", null);
> {code}
> In Camel 2.x (tested with 2.24.1 and 2.25.1), we get the expected log:
> {noformat}
> 13:58:06,685 | WARN | main | error | Exchange[ExchangePattern: InOnly, BodyType: null, Body: [Body is null], CaughtExceptionType: java.lang.Exception, CaughtExceptionMessage: Something wrong]
> {noformat}
> But in Camel 3.x (tested with 3.0.0, 3.1.0 and 3.2.0), the caught exception is not shown:
> {noformat}
> 13:55:19,904 | WARN | main | error | Exchange[ExchangePattern: InOnly, BodyType: null, Body: [Body is null]]
> {noformat}
> However, with {{showAll=true}}, the caught exception is correctly shown:
> {noformat}
> 13:58:41,258 | WARN | main | error | Exchange[Id: ID-EBEBRPCLDV0019-1588420721258-0-1, ExchangePattern: InOnly, Properties: {CamelExceptionCaught=java.lang.Exception: Something wrong, CamelToEndpoint=log://error?level=WARN&showAll=true}, Headers: {}, BodyType: null, Body: [Body is null], CaughtExceptionType: java.lang.Exception, CaughtExceptionMessage: Something wrong, StackTrace: java.lang.Exception: Something wrong
> at LogTest$1.configure(LogTest.java:16)
> [...]
> {noformat}
> I went through the different migration guides but couldn't find anything about this.
> This is really blocking for our Camel 3.x migration; any workaround is welcome! (preferably through endpoint parameters)
--
This message was sent by Atlassian Jira
(v8.3.4#803005)