Chapter 7. Logging Provider

In discussing logging and its impact on performance, there are four topics to be covered:
  • console logging
  • type of appender to use
  • location of log files
  • wrapping of log statements

7.1. Console Logging

Console logging is by far the most expensive form of logging in terms of time because console output is not buffered. All configurations, except for the production configuration, have console logging enabled because it's very convenient during development. It's especially convenient when using an IDE, such as JBoss Developer Studio, and any other IDE for that matter. With console logging on, all messages that go to the log show up in the IDE, which is an advantage when doing development work. However it's a distinct disadvantage in a production environment because it's slow and expensive.
The simplest method to avoid console logging is to use the production configuration. If a new, custom configuration is to be created, base that configuration on the production configuration. To disable console logging for an existing configuration, it's necessary to edit the logging configuration file jboss-log4j.xml in the directory JBOSS_EAP_DIST/jboss-as/server/PROFILE/conf. Note that the production configuration is preconfigured with console logging disabled.
The following is an extract of the relevant sections from the production configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!-- ===================================================================== -->
<!--                                                                       -->
<!--  Log4j Configuration                                                  -->
<!--                                                                       -->
<!-- ===================================================================== -->
<!-- ====================== -->
<!-- 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="FILE"/>
</root>
</log4j:configuration>
Console logging can be disabled either by deleting the entire Appender section from the configuration file or deleting the line containing <appender-ref ref="CONSOLE"/>