log4j Logger messages are not displayed on JBoss webapp

只谈情不闲聊 提交于 2020-01-02 07:54:10

问题


I use Jboss 6 and my

static Logger logger = Logger.getLogger(Foo.class);

displays nothing

Tried adding log4 to my project, removing it, placing a log4j file on my main/resources folder, placing no log4j file and no results.

Only System.Out seems to work, but it doesn't provide all the information I would like to see

I even see Hibernate log working but not mine

What am I missing?


回答1:


Turns out my logging does work. Hibernate logging is controlled by the jboss logging settings.

My logging began to work as soon as I placed the log4j on right next to the classes folder, and placing log4j jar with the project




回答2:


JBoss AS 6 doesn't use log4j by default anymore. Cause log4j 1.2.x proved to be vulnerable to deadlocks and performance problems.

Google suggests plenty of links on using log4j with JBoss AS 6:

Where do you configure log4j settings in jboss6

http://www.mastertheboss.com/jboss-application-server/325-using-log4j-with-jboss-6.html

http://community.jboss.org/thread/154993

http://community.jboss.org/thread/160796

http://community.jboss.org/thread/159862

But I would suggest switching apps from log4j to slf4j, using jboss-6.0.0.Final/common/lib/slf4j-jboss-logmanager.jar adapter and having all logging configuration in single jboss-logging.xml.



来源:https://stackoverflow.com/questions/8814498/log4j-logger-messages-are-not-displayed-on-jboss-webapp

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