Using log4j with JBoss 7.1
How can I use log4j with JBoss 7.1?
I have a log4j-1.2.16.jar in my WebContent/WEB-INF/lib folder. When I output the result of Logger.getRootLogger().getClass().toString()
I get class org.jboss.logmanager.log4j.BridgeLogger
which is wrong.
If I add Dependencies: org.apache.commons.logging
to my MANIFEST.MF file I get the same result.
This results into the problem that my log4j.properties file (which I created unter WEB-INF/classes) is ignored.
Solution 1:
There will soon be a way that will just work for you, but currently you have to exclude the log4j dependency from your deployment. You will also have to manually invoke the PropertyConfigurator.configure() to load the properties file.
The following file (jboss-deployment-structure.xml) needs to contain the following:
<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>
Then adding including your own version of log4j in the WEB-INF/lib
directory should work as you expect it to.