I've just switched from Tomcat to JBoss and my 1st big problem is that I can't prepare my own log4j.xml file in web application deployed on JBoss. It is not loaded during application starts. I have logging but it is from default JBoss logging configuration
I found that in the newest JBoss 7.2.0 log4j should work out of the box. But it doesn't for me. I tried all the tricks/hints/hacks I had googled - and it is so frustrated.
I would like to have log4j.xml somewhere in my project. Ideally I don't want to modify configuration inside jboss server directory because it has to work - not only on my local, but in other environments too (e.g. openshift).
pom.xml:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>provided</scope>
</dependency>
Structure:
WEB-INF/classes/log4j.xml - Contains rubbish data to check if JBoss read it (should throw exception once it load this file). I tried also copying this file into /resources, /, WEB-INF.
WEB-INF/jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<dependencies>
<module name="org.slf4j"/>
<module name="org.apache.log4j" />
</dependencies>
</deployment>
</jboss-deployment-structure>
Do I need to have external loader which load my log4j file?
Update #1 WEB-INF/classes/log4j.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' debug="true">
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
</layout>
</appender>
<root>
<priority value ="debug" />
<appender-ref ref="STDOUT" />
</root>
</log4j:configuration>
Somewhere in my code:
private static final Logger log = LoggerFactory.getLogger(TaskResource.class);
...
log.debug("deubg");