You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/12/30 13:33:29 UTC

[GitHub] [camel-quarkus] ennishol opened a new issue #2099: MDC not logging overriden breadcrumbId or custom property

ennishol opened a new issue #2099:
URL: https://github.com/apache/camel-quarkus/issues/2099


   Configured log to print MDC fields camel.exchangeId, camel.breadcrumbId and custom property 'traceId'. Only camel.exchangeId is printed in log, however twice as it is also the breadcrumbId. Code and log output:
   ```
   quarkus.log.level=INFO
   quarkus.log.console.enable=true
   quarkus.log.console.color=true
   quarkus.log.console.format=  (%t) %X{camel.exchangeId} %X{camel.breadcrumbId} %X{traceId} %s%e%n
   ```
   ```java
   @ApplicationScoped
   public class SimpleRoute  extends EndpointRouteBuilder {
   
       @Override
       public void configure() throws Exception {
           getContext().setUseMDCLogging(true);
           getContext().setUseBreadcrumb(true);
           from("timer://first?period=5000")
                   .setHeader(Exchange.BREADCRUMB_ID, constant("bar"))
                   .setProperty(Exchange.BREADCRUMB_ID, constant("bar"))
                   .setProperty("traceId", constant("bar"))
                   .setHeader("traceId", constant("bar"))
                   .log("processing done");
       }
   }
   ```
   
   ```log
   (Camel (camel-26) thread #42 - timer://first) 0FC1A7169D4FB9B-0000000000000001 0FC1A7169D4FB9B-0000000000000001  processing done
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] jamesnetherton commented on issue #2099: MDC not logging overriden breadcrumbId or custom property

Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on issue #2099:
URL: https://github.com/apache/camel-quarkus/issues/2099#issuecomment-762787424


   You need `camel-quarkus-main` on the classpath in order for the auto discovery of the `UnitOfWorkFactory` to happen.
   
   Otherwise you could do it manually in the `RouteBuilder`:
   
   ```java
   public void configure() {
               getContext().getExtension(ExtendedCamelContext.class).setUnitOfWorkFactory(new CustomUnitOfWorkFactory());
   }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] jamesnetherton commented on issue #2099: MDC not logging overriden breadcrumbId or custom property

Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on issue #2099:
URL: https://github.com/apache/camel-quarkus/issues/2099#issuecomment-753892519


   Does your example work in plain Camel without Quarkus? 
   
   `MDCUnitOfWork` handles adding fields to the MDC and it probably runs before you attempt to override `camel.breadcrumbId`.
   
   If you want to override the default behaviour, you can extend `MDCUnitOfWork`. There's an old stackoverflow.com thread that talks about it (might need some adapting for Camel 3.x):
   
   https://stackoverflow.com/questions/29045419/apache-camel-mdc-add-field-from-body
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ennishol commented on issue #2099: MDC not logging overriden breadcrumbId or custom property

Posted by GitBox <gi...@apache.org>.
ennishol commented on issue #2099:
URL: https://github.com/apache/camel-quarkus/issues/2099#issuecomment-762748435


   @jamesnetherton another observation, gelf logger is logging correctly:
   ```quarkus.log.handler.gelf.include-full-mdc=true```
   and then, camel_breadcrumbId is logged with value set


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ennishol commented on issue #2099: MDC not logging overriden breadcrumbId or custom property

Posted by GitBox <gi...@apache.org>.
ennishol commented on issue #2099:
URL: https://github.com/apache/camel-quarkus/issues/2099#issuecomment-762794895


   @jamesnetherton Thank you! that worked.
   In case someone need it. You have to override beforeProcess method in your CustomUnitOfWork implementation
   ```java
       @Override
       public AsyncCallback beforeProcess(Processor processor, Exchange exchange, AsyncCallback callback) {
           String value = exchange.getIn().getHeader(Exchange.BREADCRUMB_ID, String.class);
           if (value != null) {
               MDC.put("camel." + Exchange.BREADCRUMB_ID, value);
           }
           return super.beforeProcess(processor, exchange, callback);
       }
   ```
   
   then in config file use format ```%X{camel.breadcrumbId}```
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ennishol commented on issue #2099: MDC not logging overriden breadcrumbId or custom property

Posted by GitBox <gi...@apache.org>.
ennishol commented on issue #2099:
URL: https://github.com/apache/camel-quarkus/issues/2099#issuecomment-762783935


   @jamesnetherton ``` @Unremovable``` doesn't help. Factory still not called. I've also injected it into the route to make sure it is not removed


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] jamesnetherton commented on issue #2099: MDC not logging overriden breadcrumbId or custom property

Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on issue #2099:
URL: https://github.com/apache/camel-quarkus/issues/2099#issuecomment-762780813


   > I've implemented CustomUnitOfWorkFactory but it is not picked up by camel
   
   Add the `@Unremovable` annotation, otherwise Quarkus will clean up unused beans.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ennishol commented on issue #2099: MDC not logging overriden breadcrumbId or custom property

Posted by GitBox <gi...@apache.org>.
ennishol commented on issue #2099:
URL: https://github.com/apache/camel-quarkus/issues/2099#issuecomment-762776682


   I've implemented CustomUnitOfWorkFactory but it is not picked up by camel
   ```java
   @ApplicationScoped
   public class CustomUnitOfWorkFactory implements UnitOfWorkFactory {
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ennishol commented on issue #2099: MDC not logging overriden breadcrumbId or custom property

Posted by GitBox <gi...@apache.org>.
ennishol commented on issue #2099:
URL: https://github.com/apache/camel-quarkus/issues/2099#issuecomment-753929407


   @jamesnetherton yes, it worked without quarkus. Would be nice if it would work also with quarkus out of the box


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org