被jboss7/eap的日志问题搞死了,查了好多资料,都是war包的,基本上使用jboss-deployment-structure.xml放到WEB-INF下,文件内容如下:
<?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure> <deployment> <!-- Exclusions allow you to prevent the server from automatically adding some dependencies --> <exclusions> <module name="org.apache.log4j" /> </exclusions> </deployment> </jboss-deployment-structure>
但是我总是没法成功,最后查到是ear包的问题,和war的解决方式不同。也是使用jboss-deployment-structure.xml文件,放到ear包的META-INF下。文件内容:
<?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure> <deployment> <exclusions> <module name="org.slf4j"/> <module name="org.slf4j.impl" /> <module name="org.apache.log4j" /> </exclusions> <dependencies> <!--<module name="org.apache.log4j"/>--> </dependencies> </deployment> <sub-deployment name="myejb.jar"> <exclusions> <module name="org.apache.log4j"/> <module name="org.apache.commons.logging"/> <module name="org.log4j"/> <module name="org.jboss.logging"/> </exclusions> </sub-deployment> <sub-deployment name="myweb.war"> <exclusions> <module name="org.apache.log4j"/> <module name="org.apache.commons.logging"/> <module name="org.log4j"/> <module name="org.jboss.logging"/> </exclusions> </sub-deployment> </jboss-deployment-structure>
其中sub-deployment是我自己的2个工程,一个myejb.jar是ejb工程,一个myweb.war是web工程,在这里配置就可以了。也不用手动加载log4j配置文件啥的,logj配置文件直接放在classes目录中就可以,配置了就好用。记录备案阿,太费劲了