Log4j en JBoss AS 7

Para utilizar una configuración de logj4 personalizada desde la propia aplicación, necesitaremos incluir el fichero log4j.xml.


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
  <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
   <appender name="R" class="org.apache.log4j.RollingFileAppender">
    <param name="File" value="${jboss.server.log.dir}/myapp.log" />
    <param name="Append" value="true"/>
    <param name="MaxFileSize" value="1MB" />
    <param name="MaxBackupIndex" value="5" />
    <layout class="org.apache.log4j.PatternLayout">
     <param name="ConversionPattern" value="%d{dd/MM/yyyy hh:mm:ss} %-5p [%c] %m%n"/>
  <!-- The "category" represents the package names of your Application APIs which we want to log -->
  <category name="com.myapp">
   <priority value="INFO" />
   <appender-ref ref="R" />
   <priority value="INFO" />
   <appender-ref ref="R"/>

Además es necesario que nuestro .war contenga la libreria WEB-INF/lib/log4j-1.2.16.jar



Así como indicar explicitamente a JBoss, que no utilize su propia libreria y configuración mediante este fichero:

<?xml version="1.0" encoding="UTF-8"?>
        <module name="org.apache.log4j" />

* http://middlewaremagic.com/jboss/?p=1458


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.