Chapter 42. Logging

HornetQ has its own logging delegate that has no dependencies on any particular logging framework. The default delegate delegates all its logs to the standard JDK logging, (a.k.a Java-Util-Logging: JUL). By default the server picks up its JUL configuration from a logging.properties file found in the config directories. This is configured to use our own HornetQ logging formatter and will log to the console as well as a log file. For more information on configuring JUL visit Suns website.

You can configure a different Logging Delegate programatically or via a System Property.

To do this programatically simply do the following

org.hornetq.core.logging.Logger.setDelegateFactory(new Log4jLogDelegateFactory())

Where Log4jLogDelegateFactory is the implementation of org.hornetq.spi.core.logging.LogDelegateFactory that you would like to use.

To do this via a System Property simply set the property org.hornetq.logger-delegate-factory-class-name to the delegate factory being used, i.e.

-Dorg.hornetq.logger-delegate-factory-class-name=org.hornetq.integration.logging.Log4jLogDelegateFactory

As you can see in the above example HornetQ provides some Delegate Factories for your convenience. these are

  1. org.hornetq.core.logging.impl.JULLogDelegateFactory - the default that uses JUL.

  2. org.hornetq.integration.logging.Log4jLogDelegateFactory - which uses Log4J

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

42.1. Logging With The JBoss Application Server

When HornetQ is deployed within the JBoss Application Server version 5.x or above 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. In versions before this you must specify what logger delegate you want to use.