简体   繁体   English

以编程方式添加Log4J附加程序

[英]Adding Log4J appenders programmatically

Ok, so I have this stupid library I'm using (documentum DFC), which does a check to see if Logger.getRootLogger().getAllAppenders().hasMoreElements() == false , if so, it resets my rootLogger level to WARN , which destroys my logging after that. 好的,所以我有一个正在使用的愚蠢的库(documentum DFC),该库进行检查以查看Logger.getRootLogger().getAllAppenders().hasMoreElements() == false ,如果这样,它将rootLogger级别重置为WARN ,此后破坏了我的日志记录。 So in an effort to stop this, I'm attempting to add an appender to the root logger just to see if I can get it to stop doing that code. 因此,为了阻止这种情况,我正在尝试向根记录器添加一个追加器,以查看是否可以停止执行该代码。 However when I call 但是当我打电话

Logger.getRootLogger().addAppender(new ConsoleAppender()); that function is still coming up false. 该功能仍然错误。 Has anyone run into this? 有人碰到这个吗?

I'm using whatever log4j version comes with jboss 6, it doesn't say in the jar file name. 我正在使用jboss 6随附的任何log4j版本,它在jar文件名中都没有说明。

I do have similar problems. 我确实有类似的问题。 I can add an appender, writing to a memory string but this never works. 我可以添加一个追加程序,将其写入内存字符串,但这是行不通的。 For me it seems like JBoss does use/modify log4J in a way, that this code modification is no longer possible, see also here: https://issues.jboss.org/browse/JBAS-9318 对我来说,似乎JBoss确实以某种方式使用/修改了log4J,不再可能进行此代码修改,另请参见: https ://issues.jboss.org/browse/JBAS-9318

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

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