7.2. Appenders

Console logging is a form of appender and there are two other main types of file based appenders, one that writes synchronously and the other asynchronously. The amount of data logged by an application can vary greatly according to what the application does and how it behaves. If a problem occurs in the background, for instance, there may be a sudden increase in logging occurrences, resulting in performance degradation of the application. The asynchronous appender is recommended over the synchronous appender because it will generally perform better. The difference in performance varies on the amount of logging that is typical for the application.
The easiest method of using the asynchronous appender is to use the production configuration or base a new configuration on it because it (as noted earlier) has console logging disabled but the asynchronous appender enabled. The configuration file to be modified is jboss-log4.xml in the directory JBOSS_EAP_DIST/jboss-as/server/<PROFILE>/conf.
The following is an extract of the two relevant sections from the production configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!-- ===================================================================== -->
<!--                                                                       -->
<!--  Log4j Configuration                                                  -->
<!--                                                                       -->
<!-- ===================================================================== -->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<!-- ====================== -->
<!-- More Appender examples -->
<!-- ====================== -->
<!-- Buffer events and log them asynchronously -->
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
   <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
   <appender-ref ref="FILE"/>
   <!--
   <appender-ref ref="CONSOLE"/>
   <appender-ref ref="SMTP"/>
   -->
</appender>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->
<root>
   <!--
       Set the root logger priority via a system property. Note this is parsed by log4j,
       so the full JBoss system property format is not supported; e.g.
       setting a default via ${jboss.server.log.threshold:WARN} will not work.
   -->
   <priority value="${jboss.server.log.threshold}"/>
   <!-- appender-ref ref="CONSOLE"/ -->
   <appender-ref ref="ASYNC"/>
</root>
</log4j:configuration>
In the ASYNC appender configuration, the FILE-based appender is active but the CONSOLE and SMTP appenders are explicitly excluded. In the Root category, the Appender reference is ASYNC, enabling the asynchronous appender.