Externalize log4j configuration
lynchmaniac Aug 1, 2013 8:46 AMHi,
I would like to externalize the log4j configuration (log4j.xml) from my application.
I have put a jboss-deployment-structure.xml in the META/INF. It looks like this :
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.infinispan" export="true"/>
</dependencies>
<exclusions>
<module name="org.slf4j" />
<module name="org.jboss.log4j.logmanager" />
<module name="org.apache.commons.logging" />
<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.impl" />
</exclusions>
</deployment>
<sub-deployment name="XXXX.ear">
<exclusions>
<module name="org.slf4j" />
<module name="org.jboss.log4j.logmanager" />
<module name="org.apache.commons.logging" />
<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.impl" />
</exclusions>
</sub-deployment>
</jboss-deployment-structure>
This is to use my own log4j component in JBoss. But how can configure JBoss to use my log4j.xml ?
I've created a custom module com/mycompagny/log/main where i put a module.xml :
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="fr.compagny.project.log">
<resources>
<resource-root path="log4j-1.2.16.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
The log4j-1.2.16.jar is in the main of the module with the log4j.xml. Th structure is like that :
log
--main
----------module.xml
----------log4j.xml
----------log4j-1.2.16.jar
I'v put a MANIFEST.MF in the META/INF with this content :
Manifest-Version: 1.0
Dependencies: xx.xxx.xxxx.xxx.log
But JBoss doesn't understand how to log with log4j. The purpose is to externalize the whole configuration of logging from my application. The ideal would be a change in the file puisser be understood by the server hot.
Is anyone have an idea to log with log4j configuration externalize ?