How can I log the processing of a Message?

Camel provides many ways to log the fact that you are processing a message. Here are just a few examples:

  • You can use the Log component which logs the Message content.

  • You can use the Tracer which trace logs message flow.

  • You can also use a Processor or Bean and log from Java code.

  • You can use this log EIP.


The Log eip supports 6 options, which are listed below.

Name Description Default Type


Required Sets the log message (uses simple language).



Sets the logging level. The default value is INFO.

Enum values:



  • INFO

  • WARN


  • OFF




Sets the name of the logger.



To use slf4j marker.



To refer to a custom logger instance to lookup from the registry.



Whether to disable this EIP from the route during build time. Once an EIP has been disabled then it cannot be enabled later at runtime.




Sets the description of this node.


Difference between Log EIP and Log component

This log EIP is much lighter and meant for logging human logs such as Starting to do …​ etc. It can only log a message based on the Simple language.

The log component is meant for logging the message content (body, headers, etc.). There are many options on the log component to configure what content to log.


You can use the log EIP which allows you to use Simple language to construct a dynamic message which gets logged.

For example, you can do

    .log("Processing ${id}")

And in XML:

  <from uri="direct:start"/>
  <log message="Processing ${id}"/>
  <to uri="bean:foo"/>

This will be evaluated using the Simple to construct the String containg the message to be logged.

Logging message body with streaming

If the message body is stream based, then logging the message body, may cause the message body to be empty afterwards. See this FAQ. For streamed messages you can use Stream caching to allow logging the message body and be able to read the message body afterwards again.

The log DSL have overloaded methods to set the logging level and/or name as well.

    .log(LoggingLevel.DEBUG, "Processing ${id}")

and to set a logger name

    .log(LoggingLevel.DEBUG, "com.mycompany.MyCoolRoute", "Processing ${id}")

The logger instance may be used as well:

    .log(LoggingLevel.DEBUG, org.slf4j.LoggerFactory.getLogger("com.mycompany.mylogger"), "Processing ${id}")

For example you can use this to log the file name being processed if you consume files.

    .log(LoggingLevel.DEBUG, "Processing file ${file:name}")

In Spring DSL it is also easy to use log DSL as shown below:

<route id="foo">
    <from uri="direct:foo"/>
    <log message="Got ${body}"/>
    <to uri="mock:foo"/>

The log tag has attributes to set the message, loggingLevel and logName. For example:

<route id="baz">
    <from uri="direct:baz"/>
    <log message="Me Got ${body}" loggingLevel="FATAL" logName="com.mycompany.MyCoolRoute"/>
    <to uri="mock:baz"/>

Using custom logger

It is possible to reference an existing logger instance. For example:

<bean id="myLogger" class="org.slf4j.LoggerFactory" factory-method="getLogger">
    <constructor-arg value="com.mycompany.mylogger" />

<route id="moo">
    <from uri="direct:moo"/>
    <log message="Me Got ${body}" loggerRef="myLogger"/>
    <to uri="mock:baz"/>

Configuring logging name

The log message will be logged at INFO level using the route id as the logger name. So for example if you have not assigned an id to the route, then Camel will use route-1, route-2 as the logger name.

For example to use "fooRoute" as the route id, you can do:

    .log("Processing ${id}")

And in XML:

<route id="fooRoute">
  <from uri="direct:start"/>
  <log message="Processing ${id}"/>
  <to uri="bean:foo"/>

Using custom logger from the Registry

If the Log EIP has not been configured with a specific logger to use, then Camel will will lookup in the Registry if there is a single instance of org.slf4j.Logger.

If such an instance exists then this logger is used, if not the behavior defaults to creating a new instance of logger.

Configuring logging name globally

You can configure a global log name that is used instead of the route id, by setting the global option on the CamelContext.

In Java you can do:

camelContext.getGlobalOptions().put(Exchange.LOG_EIP_NAME, "com.foo.myapp");

And in XML:

    <property key="CamelLogEipName" value="com.foo.myapp"/>

Masking sensitive information like password

You can enable security masking for logging by setting logMask flag to true. Note that this option also affects Log component.

To enable mask in Java DSL at CamelContext level:


And in XML you set the option on <camelContext>:

<camelContext logMask="true">


You can also turn it on|off at route level. To enable mask in Java DSL at route level:

    .log("Processing ${id}")

And in XML:

<route logMask="true">


Using custom masking formatter

org.apache.camel.support.processor.DefaultMaskingFormatter is used for the masking by default. If you want to use a custom masking formatter, put it into registry with the name CamelCustomLogMask. Note that the masking formatter must implement org.apache.camel.spi.MaskingFormatter.

The know set of keywords to mask is gathered from all the different component options, that are marked as secret. The list is generated into the source code in org.apache.camel.util.SensitiveUtils. At this time of writing there is more than 65 different keywords.

Custom keywords can be added as shown:

DefaultMaskingFormatter formatter = new DefaultMaskingFormatter();

camelContext.getRegistry().bind(MaskingFormatter.CUSTOM_LOG_MASK_REF, formatter);