Hello All, We are using Camel in Karaf and recently we upgraded Karaf to version 4.2.1 and camel to 3.18.3. I am not sure if it is a bug or if I am doing something wrong, but it seems as if when I want to use the DefaultErrorHandler to log errors to a specific log file it doesn't work anymore. In previous versions we used the LoggerErrorHandler for this but apparently it has been removed therefore the DefaultErrorHandler would be the right candidate for the replacement.
I have a logger configured in org.ops4j.pax.logging.cfg file like so: log4j2.logger.ErrorLoggingTestServiceError.name = ErrorLoggingTestServiceErrorLogger log4j2.logger.ErrorLoggingTestServiceError.level = ERROR log4j2.logger.ErrorLoggingTestServiceError.appenderRef.ErrorLoggingTestServiceError.ref = ErrorLoggingTestServiceError log4j2.appender.ErrorLoggingTestServiceError.name = ErrorLoggingTestServiceError log4j2.appender.ErrorLoggingTestServiceError.type = RollingFile log4j2.appender.ErrorLoggingTestServiceError.fileName = ${custom.logs.path}/ErrorLoggingTestService/ErrorLoggingTestService-Error.log log4j2.appender.ErrorLoggingTestServiceError.filePattern = ${custom.logs.path}/ErrorLoggingTestService/ErrorLoggingTestService-Error.%i.log.gz log4j2.appender.ErrorLoggingTestServiceError.immediateFlush = true log4j2.appender.ErrorLoggingTestServiceError.append = true log4j2.appender.ErrorLoggingTestServiceError.layout.type = PatternLayout log4j2.appender.ErrorLoggingTestServiceError.layout.pattern = ${log4j2.patternCamel} log4j2.appender.ErrorLoggingTestServiceError.policies.type = Policies log4j2.appender.ErrorLoggingTestServiceError.policies.size.type = SizeBasedTriggeringPolicy log4j2.appender.ErrorLoggingTestServiceError.policies.size.size = 50MB The ErrorLoggingTestService looks like this: <?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint-3.18.3.xsd"> <import resource="file:${karaf.etc}/services/service-base.xml"/> <bean id="demoIllegalStateException" class="java.lang.IllegalStateException"> <argument index="0" value="Forced Exception" type="java.lang.String"/> </bean> <bean id="defaultErrorLogger" class="org.slf4j.LoggerFactory" factory-method="getLogger"> <argument value="ErrorLoggingTestServiceErrorLogger"/> </bean> <camelContext id="ErrorLoggingTestService" useMDCLogging="true" errorHandlerRef="defaultEH" xmlns="http://camel.apache.org/schema/blueprint"> <errorHandler id="defaultEH" logName="ErrorLoggingTestServiceErrorLogger" level="ERROR"/> <!-- <onException>--> <!-- <exception>java.lang.Exception</exception>--> <!-- <handled>--> <!-- <constant>true</constant>--> <!-- </handled>--> <!-- <log logger="defaultErrorLogger" loggingLevel="ERROR"--> <!-- message="Logging to explicit logger"/>--> <!-- </onException>--> <route id="main-route"> <from uri="timer://runOnce?repeatCount=1&delay=1000"/> <log message="Test 2" loggingLevel="ERROR"/> <setBody> <constant>Log-Message from Camel Context.</constant> </setBody> <to uri="log:ErrorLoggingTestService?level=ERROR"/> <throwException ref="demoIllegalStateException"/> </route> </camelContext> </blueprint> Now when the onException is not commented out and the defaultErrorLogger bean is used the log is written so the logger configuration should be ok, however the defaultEH error handler does not write into the log file. I have tried to set the log name in different ways even as a bean with the DefaultErrorHandlerBuilder class to no avail. The error log is created, but no logs are written to it. Does anyone have an idea where the problem is in my code or at least a working example where the ERROR logs would be written in a separate log file. Best Regards, Erne CENIT AG, Industriestrasse 52-54, 70565 Stuttgart, Tel.: +49 711 7825-30, Fax: +49 711 7825-4000, Internet: www.cenit.com Geschaeftsstellen (Branch Offices): Berlin, Frankfurt, Hamburg, Hannover, Muenchen, Oelsnitz, Ratingen, Saarbruecken Vorstandsmitglieder (Members of the Board): Peter Schneck, Axelle Maze Aufsichtsratsmitglieder (Supervisory Board Members): Rainer Koppitz (Vorsitzender des Aufsichtsrats / Chairman of the Supervisory Board), Prof. Dr. Isabell Welpe, Ricardo Malta Bankverbindungen (Bank Accounts): Deutsche Bank (BLZ 600 700 70) Kto. 1661 040 IBAN : DE85 6007 0070 0166 1040 00 SWIFT-CODE : DEUTDESS, Commerzbank (BLZ 600 400 71) Kto. 532 015 500 IBAN : DE83 6004 0071 0532 0155 00 SWIFT-Code : COBADEFF600, Registergericht (Registry court): Amtsgericht Stuttgart Handelsregister (Commercial Register): HRB Nr. 19117 Umsatzsteuer (VAT) ID: DE 147 862 777