Version 1

    This document is based on the configuration of AS 5. Configuration may vary in other versions.

     

    In order to configure JBoss to use additional log4j appenders, the following basic steps are required:

      1. Create appender - create a jar archive (e.g. myappender.jar). Copy the library archive and all dependant libraries to JBOSS_HOME/lib
      2. Update JBoss startup parameters to include these jars in the boot classpath.
      3. Add appender definition and references in the log4j config file

     

    1. Creating the appender

    The appender class should extend org.apache.log4j.AppenderSkeleton.

     

    2. Update jboss startup parameters

    If you are using the default JBoss startup script from JBOSS_HOME/bin/run.sh or run.bat, then this can be accomplished by the following modification:

     

    @@ -116,4 +116,6 @@
    fi
    JBOSS_BOOT_CLASSPATH="$runjar"
    +logjar="$JBOSS_HOME/lib/MyLogAppender.jar:$JBOSS_HOME/lib/log4j-boot.jar:$JBOSS_HOME/lib/SomeLibrary.jar"
    +JBOSS_BOOT_CLASSPATH="$JBOSS_BOOT_CLASSPATH:$logjar"

    # Tomcat uses the JDT Compiler

     

    The above modification assumes that MyLogAppender.jar is the primary library, with SomeLibrary.jar being the dependant libraries. log4j-boot.jar is distributed with JBoss, and contains the AppenderSkeleton class.

     

    3. Update log4j configuration

    The default log4j configuration is in JBOSS_HOME/server/<configuration>/conf/jboss-log4j.xml

     

    <appender name="MYAPPENDER">
                    <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler" />
                    <param name="myAppenderParam1" value="someValue" />
                    <param name="Threshold" value="INFO" />
            </appender>

     

    <!-- more appenders -->

     

    <category name="my.company.package">

    <priority value="WARN" />

      <appender-ref ref="MYAPPENDER" />

    </category>

     

    <root>

      <priority ....>

      <appender-ref ref="MYAPPENDER" />

      <appender-ref ref="FILE" />

    </root>