码迷,mamicode.com
首页 > 其他好文 > 详细

Getting logback and slf4j to work in JBoss AS 7

时间:2014-12-02 18:55:34      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:http   io   ar   os   sp   for   on   art   log   

As usual, it has to do with classloading and that JBoss internally also uses slf4j and logback. As everyone seems to state just about everywhere, JBoss classloading has completely changed in AS 7. Here‘s the recipe for this particular problem.

Create a file called "jboss-deployment-structure.xml" in the META-INF directory for an EAR or WEB-INF directory for a WAR. This file can contain a lot of different stuff to tweak the classloader, but for the logback case this is enough:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
   <deployment>
      <exclusions>
         <module name="org.apache.commons.logging" />
         <module name="org.apache.log4j" />
         <module name="org.jboss.logging" />
         <module name="org.jboss.logging.jul-to-slf4j-stub" />
         <module name="org.jboss.logmanager" />
         <module name="org.jboss.logmanager.log4j" />
         <module name="org.slf4j" />
         <module name="org.slf4j.impl" />
      </exclusions>
   </deployment>
</jboss-deployment-structure>


For the EAR case, you‘ll probably need to add a subdeployment for each application (both wars and ejbs) with the same exclusions. For more details, consult the JBoss documentation on the subject.

UPDATE

I ran into the same issue with log4j2 on EAP 6.3 and the recipe still works. It is important to add a separate exclusion for each sub-deployment or JBoss will eat your log messages and they‘ll go into the JBoss internal logger. 

Getting logback and slf4j to work in JBoss AS 7

标签:http   io   ar   os   sp   for   on   art   log   

原文地址:http://www.cnblogs.com/chenzc/p/4137963.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!