How to configure log4j for JBoss EAP 6.0.1?
madhusudhanraju_26 Aug 10, 2013 9:35 AMHi,
We are in process of migrating from JBoss 5.1.2 to JBoss 6.0.1 EAP.
While deploying the EAR file in "JBoss-5.1\server\deploy" directory, we package log4j.jar in the application (war and jar) library and configured logging using jboss-log4j.xml under
"JBoss-5.1"\server\conf directory. Our package is as follows:
Myear.ear
|----myWar.war
|----myJar.jar
We are now able to run the application in JBoss-6.0.1 successfully with some modifications according to JBoss 6.0.1 Admin guide, but only issue is around the application logging.
While running the appliaction on JBoss-6.0.1 except DEBUG level log statements, INFO, ERROR, FATAL, WARN logs are getting logged to server.log.
I've packaged log4j.jar under "myWar.war/Web-Content/WEB-INF/lib" directory logging in standalone.xml as below:
<subsystem xmlns="urn:jboss:domain:logging:1.1">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE">
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.arjuna">
<level name="WARN"/>
</logger>
<logger category="org.apache.tomcat.util.modeler">
<level name="WARN"/>
</logger>
<logger category="sun.rmi">
<level name="WARN"/>
</logger>
<logger category="jacorb">
<level name="WARN"/>
</logger>
<logger category="jacorb.config">
<level name="ERROR"/>
</logger>
<logger category="org.jboss">
<level name="INFO"/>
</logger>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
If am setting the category to "org.jboss" and level to DEBUG, it is logging FINE, FINER and FINEST logs which is increasing the server.log enormosly.
I see a log4j.jar under "JBoss-6.0.1\module\org\apache\log4j\main\" i removed the log4j.jar under the lib and configured the module.xml file in "JBoss-6.0.1\module\org\apache\log4j\main\" as following
<module xmlns="urn:jboss:module:1.1" name="org.apache.log4j">
<resources>
<resource-root path="log4j-1.2.16-redhat-2.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="org.dom4j" optional="true"/>
<module name="org.jboss.logmanager"/>
<module name="org.jboss.modules"/>
</dependencies>
</module>
With above configuration, when JBoss is started i get to see the below erro and server fails to start:
05:20:35,924 ERROR [stderr] (ajp-/127.0.0.1:8009-1) log4j:WARN No appenders could be found for logger (app.com.servlet.MyServlet).
05:20:35,924 ERROR [stderr] (ajp-/127.0.0.1:8009-1) log4j:WARN Please initialize the log4j system properly.
05:20:35,925 ERROR [stderr] (ajp-/127.0.0.1:8009-1) log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
05:59:47,388 INFO [org.jboss.as.osgi] (MSC service thread 1-1) JBAS011908: Unregister module: Module "deployment.Myear.ear.Mywar.war:main" from Service Module Loader
How can i use this "log4j-1.2.16-redhat-2.jar" provided by JBoss 6.0.1 for my application logging by supressing the FINE, FINER and FINEST logs which are getting generated by sqljdbc.jar whenever application is connecting to database.
Can someone pls help me in logging DEBUG statements to server.log file?