We have a simple Camel route like below. But we have noticed that errorHandler 
log is not working. After some investigation, we understood that errorHandler 
has different log parameters then other logs(like in route or onException).

We haven't succeeded to use errorHandler log. Yes, there are so many options to 
log but we want to learn how to use this one. Our aim is to log some texts 
before or after sending messages to deadletter queue.
How can we use errorHandler log?

apache-camel : 3.19.0

spring-boot : 2.7.5

<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:camel="http://camel.apache.org/schema/spring";
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                http://www.springframework.org/schema/beans/spring-beans.xsd
                http://camel.apache.org/schema/spring
                http://camel.apache.org/schema/spring/camel-spring.xsd";>

    <bean id="mdcEnricher" class="com.mycompany.MDCEnricher"/>

    <camel:camelContext id="mycontext" 
xmlns="http://camel.apache.org/schema/spring"; useMDCLogging="true">

        <camel:errorHandler id="myErrorHandler" type="DeadLetterChannel"
                            useOriginalBody="true"
                            deadLetterUri="jms:queue:mybackoutq">
            <redeliveryPolicy 
                    maximumRedeliveries="1"
                    redeliveryDelay="1"
                    retryAttemptedLogLevel="WARN"
                    retriesExhaustedLogLevel="ERROR"/>
            <log id="logIncomingMsg" logName="com.mypackage"
              loggingLevel="ERROR" message="Pushing to backout queue"/>
        </camel:errorHandler>


        <camel:route id="myRoute" errorHandlerRef="myErrorHandler">
            <from uri="jms:queue:myinputq"/>
            <bean ref="mdcEnricher" method="enrich"/>
            <log message="Received exchange with message id: 
[${headers.JMSMessageID}], starting processing"/>
            <process ref="#class:com.mycompany.processor.MyProcessor"/>
            <to uri="jms:queue:myoutputq"/>
            <log message="Finished the processing exchange with message id: 
[${headers.JMSMessageID}]"/>
        </camel:route>

Try to change log configuration and loggingLevel to DEBUG but nothing changed.

<springProfile name="local">
    <logger name="org.apache.camel" level="DEBUG"/>
    <logger name="com.mycompany" level="DEBUG"/>
    <root level="DEBUG">
        <appender-ref ref="LocalConsole"/>
    </root>
</springProfile>

Reply via email to