简体   繁体   English

覆盖骆驼和log4j

[英]Overriding Camel & log4j

I'm fairly new to Apache Camel, but have to say that I love it so far. 我对Apache Camel并不陌生,但必须说到目前为止我很喜欢它。 One "limitation" (probably a lack of understanding on my part) I've hit so far is that Camel ships with log4j as its default logging component. 到目前为止,我遇到的一个“局限性”(可能是我缺乏了解)是Camel附带log4j作为其默认日志记录组件。

My team has already gone to great lengths to build our own logging framework, which ends up posting all log messages to an ActiveMQ queue, and ultimately, our database. 我的团队已经竭尽全力构建自己的日志框架,最终将所有日志消息发布到ActiveMQ队列,最终发布到我们的数据库。

I'd like to configure Camel to work with our logging framework, since so much has already been invested in getting it working. 我想将Camel配置为与我们的日志记录框架一起使用,因为已经投入了大量的精力来使其工作。 Although Camel doesn't seem to provide any documentation on this, I do have two ideas and wanted to run them by the SO community. 尽管Camel似乎没有提供任何文档,但是我确实有两个想法,并且希望由SO社区来运行。

(1) Find a way to re-configure log4j 's LoggerFactory. (1)找到一种重新配置log4j的LoggerFactory的方法。 That way we can have our own LoggerFactory return instances of our homegrown Loggers. 这样,我们可以拥有自己的本地Logger的LoggerFactory返回实例。

(2) Write our own log4j appender, which would use our homegrown Logger. (2)编写我们自己的log4j附加程序,该附加程序将使用我们自己的Logger。

Has anyone ever had experience with this? 有没有人有过这方面的经验? Is there an easier/better/more elegant solution out there? 有没有更简单/更好/更优雅的解决方案? Any input is appreciated. 任何输入表示赞赏。

Log4J already provides a JMSAppender. Log4J已经提供了JMSAppender。 You could be able to just configure one and go. 您可能只需配置一个即可。 Check out http://activemq.apache.org/how-do-i-use-log4j-jms-appender-with-activemq.html 查看http://activemq.apache.org/how-do-i-use-log4j-jms-appender-with-activemq.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM