git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem writing camel logs with log4j in a spring-boot application


Hi
I have a Spring-boot application with Apache Camel. All I am trying to
achieve here writing all logs(java log and also camel route level logs
using camel 'log' EIP) in a log file using log4j.



*My POM: *

      <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
             <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
    </exclusions>
        </dependency>

        <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-spring-boot</artifactId>
    <version>${camel.version}</version>
</dependency>

        <dependency>
   <groupId>commons-logging</groupId>
   <artifactId>commons-logging</artifactId>
   <version>1.2</version>
</dependency>
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.16</version>
   </dependency>


*LOG4J properties file: *
log4j.rootLogger=info, rollinglog, rollingerrorlog

log4j.logger.org.apache.camel=INFO

# File output configuration
log4j.appender.rollinglog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.rollinglog.File=C://logs/testgateway.log
log4j.appender.rollinglog.Threshold=INFO

# roll over the file at the end of each day and append the date to the end
of the file
log4j.appender.rollinglog.DatePattern='.'yyyy-MM-dd

# Configure the layout for the log file
log4j.appender.rollinglog.layout=org.apache.log4j.PatternLayout
log4j.appender.rollinglog.layout.ConversionPattern=(%d) %p %t %c - %m%n

# File output configuration
log4j.appender.rollingerrorlog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.rollingerrorlog.File=C://logs/ testgateway.log
log4j.appender.rollingerrorlog.Threshold=ERROR

# roll over the file at the end of each day and append the date to the end
of the file
log4j.appender.rollingerrorlog.DatePattern='.'yyyy-MM-dd

# Configure the layout for the log file
log4j.appender.rollingerrorlog.layout=org.apache.log4j.PatternLayout
log4j.appender.rollingerrorlog.layout.ConversionPattern=(%d) %p %t %c - %m%n


*My Camel route: *

<route id="test-route" autoStartup="true">
<from uri="restlet:/test"/>

<!-- Logs are getting printed correctly in expected log file from below
java method-->
<to uri="bean:sendMessage?method=test"/>

<!-- Logs are not getting printed in expected log file from below log EIP-->

<log message="HEADER: ${headers}"/>
</route>

So I am confused why camel log not getting printed from camel contexts
wjere java logs are working fine, could you please guide me what I am
missing here

-- 
Kind Regards
Rana


( ! ) Warning: include(msgfooter.php): failed to open stream: No such file or directory in /var/www/git/apache-camel-users/msg03557.html on line 159
Call Stack
#TimeMemoryFunctionLocation
10.0006368696{main}( ).../msg03557.html:0

( ! ) Warning: include(): Failed opening 'msgfooter.php' for inclusion (include_path='.:/var/www/git') in /var/www/git/apache-camel-users/msg03557.html on line 159
Call Stack
#TimeMemoryFunctionLocation
10.0006368696{main}( ).../msg03557.html:0