Spring-Camel (camel logs by default goes console a

2019-07-24 07:41发布

I am facing one strange problem , I am working on one batch application using below tech STACK Spring (IOC container) , spring batch , Hibernate , camel and Log4J for logging I have configured log4J for file appender only and my all application logs goes to my log file , but strange thing is that all Camel logs goes to console appender (I have no console apender configured on my log4J properties file)

Spring – Camel Integration is XMl element :

 <camelContext xmlns="http://camel.apache.org/schema/spring">
        <routeBuilder ref="smtBatchRouter" />
    </camelContext>

My Log4J configuration:

log4j.rootLogger=TRACE, file
log4j.logger.org.apache=TRACE
log4j.logger.org.directwebremoting=OFF
log4j.logger.org.hibernate=OFF
log4j.logger.org.springframework=WARN

log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.file=myapp.log
log4j.appender.file.ImmediateFlush=true
log4j.appender.file.bufferedIO=false
log4j.appender.file.DatePattern='.' dd-MM-yyyy
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
log4j.appender.file.threshold=TRACE

Sample Camel Log that I am getting in console :

[main] INFO org.apache.camel.spring.SpringCamelContext - Apache Camel 2.11.0 (CamelContext: camel-1) started in 4.009 seconds
[Camel (camel-1) thread #0 - sftp://xyz.com/smtDataFolder] INFO org.apache.camel.component.file.remote.SftpOperations - JSCH -> Connecting to localhost port 22
[Camel (camel-1) thread #0 - sftp://xyz.com/smtDataFolder] INFO org.apache.camel.component.file.remote.SftpOperations - JSCH -> Connection established
[Camel (camel-1) thread #0 - sftp://xyz.com/smtDataFolder] INFO org.apache.camel.component.file.remote.SftpOperations - JSCH -> Remote version string: SSH-1.99-OpenSSH_4.6

1条回答
The star\"
2楼-- · 2019-07-24 08:18

I had the same issue and solved it. Run your application with the flag:
-Dlog4j.debug
It will add diagnostic information to your console. In my case it was

SLF4J: Class path contains multiple SLF4J bindings. 

So I just deleted redundant slf4j-jdk14-1.7.9.jar and left only slf4j-log4j12-1.7.19.jar.

查看更多
登录 后发表回答