本文介绍了弹簧骆驼(默认骆驼日志云控制台附加目的地)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面对面的奇怪的问题,我在一个批处理应用程序,使用下面的高科技STACK工作
春季(IOC容器),弹簧批次,休眠,骆驼和Log4J的日志记录
我为唯一的文件追加程序配置Log4j和我所有的应用程序日志转到我的日志文件,但奇怪的是,所有的骆驼日志去安慰追加程序(我没有控制台apender我log4j属性配置文件)

春天 - 骆驼整合是XML元素:

 < camelContext的xmlns =htt​​p://camel.apache.org/schema/spring>
        < routeBuilder REF =smtBatchRouter/>
    < / camelContext>

我的Log4j配置:

  log4j.rootLogger = TRACE,文件
log4j.logger.org.apache = TRACE
log4j.logger.org.directwebremoting = OFF
log4j.logger.org.hibernate = OFF
log4j.logger.org.springframework = WARNlog4j.appender.file = org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.file = myapp.log
log4j.appender.file.ImmediateFlush =真
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

样品骆驼日志中我得到控制台:

  [主]信息org.apache.camel.spring.SpringCamelContext  -  Apache的骆驼2.11.0(CamelContext:骆驼-1)4.009秒开始
[骆驼(骆驼-1)线#0 - SFTP://xyz.com/smtDataFolder] INFO org.apache.camel.component.file.remote.SftpOperations - JSCH - >连接到本地主机端口22
[骆驼(骆驼-1)线#0 - SFTP://xyz.com/smtDataFolder] INFO org.apache.camel.component.file.remote.SftpOperations - JSCH - >连接已建立
[骆驼(骆驼-1)线#0 - SFTP://xyz.com/smtDataFolder] INFO org.apache.camel.component.file.remote.SftpOperations - JSCH - >远程版本字符串:SSH-1.99-OpenSSH_4.6


解决方案

我有同样的问题,并解决它。
运行带有标志您的应用程序:结果
     -Dlog4j.debug 结果
这将增加诊断信息到控制台。在我的情况是

  SLF4J:类路径中包含多个SLF4J绑定。

所以我只是删除多余的 SLF4J-jdk14-1.7.9.jar 键,只剩 SLF4J-log4j12-1.7.19.jar

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
解决方案

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.

这篇关于弹簧骆驼(默认骆驼日志云控制台附加目的地)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 08:17