-
Bug
-
Resolution: Done
-
Normal
-
None
-
False
-
-
False
-
-
-
-
0
-
+
The MDC breadcrumbId is not logged in the following Route at LOG.info("no breadcrumbid logged"):
package com.redhat.support.examples; import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.Predicate; import java.util.logging.Logger; import org.springframework.stereotype.Component; @Component public class MyRouteBuilder extends RouteBuilder{ public void configure() throws Exception { getContext().setUseMDCLogging(true); getContext().setUseBreadcrumb(true); onException(Exception.class) .handled(new Predicate() { Logger LOG = Logger.getLogger("example"); public boolean matches(Exchange exchange) { LOG.info("no breadcrumbid logged"); return false; } }) .log("after handled()"); from("timer:java?period={{time:1000}}").routeId("java") .log("before exception") .process(e -> { throw new RuntimeException("Random Kaboom");}) .log("after exception"); } }
The following logs are produced:
09:53:01 70E416EC38425B4-0000000000000000 INFO before exception 09:53:01 INFO no breadcrumbid logged 09:53:01 70E416EC38425B4-0000000000000000 INFO after handled()
Using the following pattern:
quarkus.log.console.format=%d{HH:mm:ss} %-32.32X{camel.breadcrumbId} %-5p %s%e%n
The issue is that the second log line ("no breadcrumbid logged") does not contain the MDC breadcrumbId. This occurs in both dev and native mode for quarkus, but in Spring-Boot the breadcrumbId is logged (using a slightly different logback formatter):
2023-05-09 12:31:44,591 [ ID-fedora-1683649903139-0-1 ] INFO before exception 2023-05-09 12:31:44,593 [ ID-fedora-1683649903139-0-1 ] INFO no breadcrumbid logged 2023-05-09 12:31:44,594 [ ID-fedora-1683649903139-0-1 ] INFO after handled()