以编程方式添加 Log4J 附加程序
好的,所以我正在使用这个愚蠢的库(documentum DFC),它会检查是否 Logger.getRootLogger().getAllAppenders().hasMoreElements() == false
,如果是的话,它将我的 rootLogger 级别重置为 WARN,这会在之后破坏我的日志记录。因此,为了阻止这种情况,我尝试向根记录器添加一个附加程序,看看是否可以让它停止执行该代码。然而当 我调用
Logger.getRootLogger().addAppender(new ConsoleAppender()); 该函数仍然出现错误。有人遇到过这个吗?
我正在使用 jboss 6 附带的任何 log4j 版本,它在 jar 文件名中没有说明。
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. 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也有类似的问题。我可以添加一个附加程序,写入内存字符串,但这永远不会起作用。
对我来说,JBoss 似乎确实以某种方式使用/修改了 log4J,这种代码修改不再可能,另请参见此处:https://issues.jboss.org/browse/JBAS-9318
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