Chapter 42. Logging

HornetQ uses standard JDK logging, (a.k.a Java-Util-Logging: JUL), for all its logging. This means we have no dependencies on any third party logging framework. Users can provide their own logging handler to use or alternatively use the log4j handler supplied by HornetQ.

The handlers are configured via the JUL logging.properties file. This default location for this file is under the lib directory found in the Java home directory but it can be overridden by setting the java.util.logging.config.file system property to point to the appropriate logging.properties file. The standalone HornetQ server does this and the logging.properties file can be found under the config directory of the HornetQ installation.

By default the standalone server is configured to use the standard console handler and a file handler that logs to bin/logs/hornetq.log.

Because some of the third party components used to bootstrap HornetQ, i.e. the Microcontainer, use the JBoss Logging framework we have supplied a plugin class that redirects this to the JUL logger. This is set via a system property, -Dorg.jboss.logging.Logger.pluginClass=org.hornetq.integration.logging.HornetQLoggerPlugin. This is only needed when starting the standalone server and is set in the run script. This is not a problem if you are embedding HornetQ in your own code as the Microcontainer won't be being used.

If you want configure your client's logging, make sure you provide a logging.properties file and set the java.util.logging.config.file property on client startup

42.1. Log4j Configuration

HornetQ supplies a JUL Log4j handler that can be used instead of the defaults if you prefer to work with log4j logs. To use this simply edit the logging.properties file as such:

handlers=org.hornetq.integration.logging.Log4jLoggerHandler

You will also need to download the Log4j jars and place them in the lib directory and also provide a log4j configuration and place it on the appropriate config directory, i.e. config/common.

42.2. Logging With The JBoss Application Server

When HornetQ is deployed within the Application Server then it will still use JUL however the logging is redirected to the default JBoss logger. For more information on this refer to the JBoss documentation.