JBoss AS 6 and Log4j
petal1 Apr 18, 2013 1:52 PMHello,
I know there are plenty of posts out there on this topic, but I am not finding any of them helpful or relevant.
I have a simple requirement. I am moving from JBoss AS 4.0.4 to JBoss AS 6. In my 4.0.4 environment I have a log4j.xml in server/myconfig/conf folder, and log4j.jar in server/myconfig/lib. I realise that JBoss AS 6 has changed to a native logging framework. We are heavily dependent on log4j and changing is not practical. I have seen many posts saying to package log4j jar and the log4j.xml file in your application. I have dozens of jar and war files in deploy and lib. Would I seriously be expected to package the log4j.jar and log4j.xml into all of them? I would hope not, so maybe setting -Djboss.as.logging.per-deployment=false will help? But I still see people saying to put log4j.jar and log4j.xml into ear/war files even with that set.
I have tried putting log4j.jar in server/myconfig/lib with a log4j.xml file in server/myconfig/conf. I have also tried adding a log4j-appender to server/deploy/jboss-logging.xml as follows:
<log4j-appender name="MYFILE" class="org.apache.log4j.RollingFileAppender">
<error-manager>
<only-once/>
</error-manager>
<level name="DEBUG"/>
<properties>
<property name="File">${jboss.server.log.dir}/serverX.log</property>
<property name="MaxFileSize">20MB</property>
<property name="MaxBackupIndex">5</property>
</properties>
<formatter>
<pattern-formatter pattern="%d %-5p [%c] (%t) %m%n"/>
</formatter>
</log4j-appender>
<root-logger>
<level name="${jboss.server.log.threshold:INFO}"/>
<handlers>
<handler-ref name="CONSOLE"/>
<handler-ref name="FILE"/>
<handler-ref name="MYFILE"/>
</handlers>
</root-logger>
but that didn't work. In fact, with the above addition to jboss-logging.xml, I did not get anything written to server.log, which I do without the above.
If someone could please tell me how I can mimic my 4.0.4 set up please then I'd be very grateful.
Thanks,
Paul