【问题标题】:Log4j - configuring AsyncAppender in log4j.propertiesLog4j - 在 log4j.properties 中配置 AsyncAppender
【发布时间】:2018-02-19 19:12:13
【问题描述】:

我已经看到了大量关于如何在 log4j.xml 中使用 AsyncAppender 的材料。但是,我不能使用 xml 配置,因为我使用的是 Jboss Fuse - 而且这项技术只允许 .properties 配置。

有没有办法将以下配置转换为 .properties?

<appender name="async" class="org.apache.log4j.AsyncAppender">
  <param name="BufferSize" value="500"/>
  <appender-ref ref="console"/>
</appender>

我想一个解决方案看起来有点像这样:

log4j.appender.async=org.apache.log4j.AsyncAppender
log4j.appender.async.appenders=console

【问题讨论】:

  • 这是否意味着 AsyncAppender 需要 XML 配置? .xml 和 .properties 可以共存吗?
  • 是的,AFAIK AsyncAppender 需要 XML 配置。在我的情况下,我使用的是 ops4j-logging(与 Jboss Fuse 捆绑在一起),因此我能够使用答案中描述的 ops4j 功能来使用属性配置来解决这个问题。
  • 我最终以编程方式编写了配置。谢谢

标签: log4j


【解决方案1】:

根据文档,这在属性配置器中是不可能的:

https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PropertyConfigurator.html

但是,由于我使用的是 Jboss Fuse,而 Jboss Fuse 使用的是 ops4j pax-logging,所以已经解决了,并且我提交了配置

log4j.appender.async.appenders=console

在 Jboss Fuse 中工作

【讨论】:

    猜你喜欢
    • 2017-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-20
    • 2017-10-26
    • 1970-01-01
    • 2016-08-29
    • 2014-08-31
    相关资源
    最近更新 更多