JBoss AS 7 Logging tuning

Logging is an essential activity of every applications, however the default configuration is generally appropriate for development, but not for a production environment.
The key elements which you need to consider when switching to production are:

1.    Choosing the appropriate handler to output your logs.
2.    Choose a log level which provides just the amount of information you need and nothing else.
3.    Choose an appropriate format for your logs

As far as it concerns, log handlers, in the default configuration, both console logging and file logging are enabled. While this can be fine for development, using console logging in production is an expensive process which causes lots of un-buffered I/O. While some applications maybe fine with console logging, high-volume applications benefit from turning off console logging and just using the FILE handler.
In order to remove console logging, you can simply comment out its handler:

  <level name="INFO"/>
     <!--   <handler name="CONSOLE"/> -->
   <handler name="FILE"/>

Next step is choosing the correct logging verbosity. Obviously, the less you log, the less I/O will occur, and the better your overall application. The default configuration uses the "INFO" level for the root logger. You could consider raising this to an higher threshold like "WARN" or (using a fine grained approach) changing the single logging categories

<logger category="org.hibernate">
  <level name="WARN"/>

In this example, we have just raised the log level for org.hibernate package to "WARN" which will produce a much more concise information from Hibernate.
Finally, also the pattern used by your logs can influence the performance of your applications. For example, let's take the default pattern format, which is:

 pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>

A detailed explanation of the logging patterns can be found in Chapter 2's section The console handler. Starting from this basic format, with as little as adding the flag %l, you can greatly enhance the verbosity of your logs by printing the line number and the class that emitted the log:

 pattern="%l %d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>

And this is the console output once the server configuration has been reloaded:

jboss 7 book performance tuning
While this information can be quite useful in development, it will result in a huge burden when ported in production.
The other flags which can have a negative impact on your logging performance are %C (which prints out the caller class information) , %M (which outputs the method where logging was emitted) and %F (which outputs the filename where the logging request was issued).