Application logging using log4j
agerson Mar 16, 2012 4:35 PMWe are using jboss-6.1.0.Final and trying to get application logging to work. Our testing is using a very simple servlet test program called Test.java. It has the normal servlet stuff and the following.
private static final Log log=LogFactory.getLog(Test.class);
.....
log.info("Test entered.");
This works just fine execpt that the output is to the server.log. It works but not a very good idea. The log entry should go to an application log like app.log. Reading a lot on the web and this forum there does not seem to be clear direction on what to do. We tried using log4j.xml and log4j.jar in the application war file and this did not work. Now I see a thread that says all you have to do is put jboss-logging.xml in your META-INF directory. Well this did now work either, because the log entries continued to be written in server.log and not app.log. The following is our jboss-logging.xml file. We did not remove the jboss-logging.xml file from the server/standard/deploy directory. I guess I am missing something but cannot figure it out. We are using Eclipse to test this little application. Thanks for any help.
<?xml version="1.0" encoding="UTF-8"?>
<!-- ===================================================================== -->
<!-- -->
<!-- Logging System Configuration -->
<!-- -->
<!-- ===================================================================== -->
<logging xmlns="urn:jboss:logging:6.0" xmlns:b="urn:jboss:bean-deployer:2.0">
<!-- ================================= -->
<!-- Preserve messages in a local file -->
<!-- ================================= -->
<!-- A time/date based rolling handler -->
<periodic-rotating-file-handler
file-name="${jboss.server.log.dir}/tan.log"
name="TAN"
autoflush="true"
append="true"
suffix=".yyyy-MM-dd">
<error-manager>
<only-once/>
</error-manager>
<formatter>
<pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/>
</formatter>
</periodic-rotating-file-handler>
<logger category="com.tanager">
<level name="INFO"/>
</logger>
<root-logger>
<level name="${jboss.server.log.threshold:INFO}"/>
<handlers>
<handler-ref name="TAN"/>
</handlers>
</root-logger>
</logging>