Adding Log4J appenders programmatically

你离开我真会死。 提交于 2019-12-11 04:51:37

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/6071809/adding-log4j-appenders-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!