简体   繁体   中英

Apache Camel Component specific logging

Is it possible to enable logging in an apache camel route only for specific components?

I know how to use the log component, and how to enable camel logging in general (for all components and your route and so on), but is it possible to enable the logging only for a specific component?

For example I have the following route (pseudo code):

from(fileendpoint)
.log("consumed file")
.choice()
     .when(condition1)
        .process([convert to json and set in exchange])
        .setHeader(Exchange.CONTENT_ENCODING, "application/xml")
        .to(http4endpoint)
     .otherwise()
        .to(anotherendpoint)
.end();

What I know want to be able to do is to enable the log only for the http4 component to see what's the real request that will be produced. But I don't need the detailed information from the other used components in the route (assuming there might be a lot more). Is there a way to accomplish that or not?

As the HTTP4 component of camel uses the Apache HTTP client (version 4) internally you should be able to add

<logger name="org.apache.http.wire" level="debug"/>

to your Log4J log configuration in order to log only your HTTP client related stuff. Other logging frameworks should be similar to configure.

对于 Spring Boot,只需将此行添加到application.yaml文件

logging.level.org.apache.http.wire: DEBUG

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM