Logging

Apache ActiveMQ Artemis uses the JBoss Logging framework to do its logging and is configurable via the logging.properties file found in the etc directory. This is configured by default to log to both the console and to a file.

There are a handful of general loggers available:

LoggerDescription
org.jboss.loggingLogs any calls not handled by the Apache ActiveMQ Artemis loggers
org.apache.activemq.artemis.core.serverLogs the core server
org.apache.activemq.artemis.utilsLogs utility calls
org.apache.activemq.artemis.journalLogs Journal calls
org.apache.activemq.artemis.jmsLogs JMS calls
org.apache.activemq.artemis.integration.bootstrapLogs bootstrap calls
org.apache.activemq.audit.baseaudit log. Disabled by default
org.apache.activemq.audit.resourceresource audit log. Disabled by default
org.apache.activemq.audit.messagemessage audit log. Disabled by default

Activating TRACE for a specific logger

Sometimes it is necessary to get more detailed logs from a particular logger. For example, when you’re trying to troublshoot an issue. Say you needed to get TRACE logging from the logger org.foo. First you would need to add org.foo to the loggers list at the top of logging.properties, e.g.:

  1. loggers=...,org.foo

Then you need to configure the logging level for the org.foo logger to TRACE, e.g.:

  1. logger.org.foo.level=TRACE

Lastly, you would need to update the level of the necessary handler to allow the TRACE logging through, e.g.:

  1. handler.CONSOLE.level=TRACE

or

  1. handler.FILE.level=TRACE

Logging in a client or with an Embedded server

Firstly, if you want to enable logging on the client side you need to include the JBoss logging jars in your application. If you are using Maven the simplest way is to use the “all” client jar, e.g.:

  1. <dependency>
  2. <groupId>org.jboss.logmanager</groupId>
  3. <artifactId>jboss-logmanager</artifactId>
  4. <version>2.1.10.Final</version>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.apache.activemq</groupId>
  8. <artifactId>activemq-core-client-all</artifactId>
  9. <version>2.16.0</version>
  10. </dependency>

There are 2 properties you need to set when starting your java program, the first is to set the Log Manager to use the JBoss Log Manager, this is done by setting the -Djava.util.logging.manager property i.e.:

  1. -Djava.util.logging.manager=org.jboss.logmanager.LogManager

The second is to set the location of the logging.properties file to use, this is done via the -Dlogging.configuration, e.g.:

  1. -Dlogging.configuration=file:///home/user/projects/myProject/logging.properties

Note:

The logging.configuration system property needs to be valid URL

The following is a typical logging.properties for a client

  1. # Root logger option
  2. loggers=org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms,org.apache.activemq.artemis.ra
  3. # Root logger level
  4. logger.level=INFO
  5. # Apache ActiveMQ Artemis logger levels
  6. logger.org.apache.activemq.artemis.core.server.level=INFO
  7. logger.org.apache.activemq.artemis.utils.level=INFO
  8. logger.org.apache.activemq.artemis.jms.level=DEBUG
  9. # Root logger handlers
  10. logger.handlers=FILE,CONSOLE
  11. # Console handler configuration
  12. handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
  13. handler.CONSOLE.properties=autoFlush
  14. handler.CONSOLE.level=FINE
  15. handler.CONSOLE.autoFlush=true
  16. handler.CONSOLE.formatter=PATTERN
  17. # File handler configuration
  18. handler.FILE=org.jboss.logmanager.handlers.FileHandler
  19. handler.FILE.level=FINE
  20. handler.FILE.properties=autoFlush,fileName
  21. handler.FILE.autoFlush=true
  22. handler.FILE.fileName=activemq.log
  23. handler.FILE.formatter=PATTERN
  24. # Formatter pattern configuration
  25. formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
  26. formatter.PATTERN.properties=pattern
  27. formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n

Configuring Audit Logging

There are 3 audit loggers that can be enabled separately and audit different types of events, these are:

  1. base: This is a highly verbose logger that will capture most events that occur on JMX beans.
  2. resource: This logs the creation of, updates to, and deletion of resources such as addresses and queues as well as authentication. The main purpose of this is to track console activity and access to the broker.
  3. message: This logs the production and consumption of messages.

Note:

All extra logging will negatively impact performance. Whether or not the performance impact is “too much” will depend on your use-case.

These three audit loggers are disabled by default in the logging.properties configuration file:

  1. loggers=...,org.apache.activemq.audit.base,org.apache.activemq.audit.message,org.apache.activemq.audit.resource
  2. ...
  3. logger.org.apache.activemq.audit.base.level=ERROR
  4. logger.org.apache.activemq.audit.base.handlers=AUDIT_FILE
  5. logger.org.apache.activemq.audit.base.useParentHandlers=false
  6. logger.org.apache.activemq.audit.resource.level=ERROR
  7. logger.org.apache.activemq.audit.resource.handlers=AUDIT_FILE
  8. logger.org.apache.activemq.audit.resource.useParentHandlers=false
  9. logger.org.apache.activemq.audit.message.level=ERROR
  10. logger.org.apache.activemq.audit.message.handlers=AUDIT_FILE
  11. logger.org.apache.activemq.audit.message.useParentHandlers=false
  12. ...

To enable the audit log change the level attributes to INFO, like this:

  1. logger.org.apache.activemq.audit.base.level=INFO
  2. ...
  3. logger.org.apache.activemq.audit.resource.level=INFO
  4. ...
  5. logger.org.apache.activemq.audit.message.level=INFO

The 3 audit loggers can be disable/enabled separately.

Once enabled, all audit records are written into a separate log file (by default audit.log).

Logging the clients remote address

It is possible to configure the audit loggers to log the remote address of any calling clients either through normal clients or through the console and JMX. This is configured by enabling a specific login module in the login config file.

  1. org.apache.activemq.artemis.spi.core.security.jaas.AuditLoginModule optional
  2. debug=false;

Note:

This needs to be the first entry in the login.config file

Note:

This login module does no authentication, it is used only to catch client information through which ever path a client takes

Use Custom Handlers

To use a different handler than the built-in ones, you either pick one from existing libraries or you implement it yourself. All handlers must extends the java.util.logging.Handler class.

To enable a custom handler you need to append it to the handlers list logger.handlers and add its configuration to the logging.configuration.

Last but not least, once you get your own handler please add it to the boot classpath otherwise the log manager will fail to load it!