Apache ActiveMQ Artemis uses the SLF4J logging facade for logging, with the broker assembly providing Log4J 2 as the logging implementation. This is configurable via the log4j2.properties file found in the broker instance etc directory, which is configured by default to log to both the console and to a file.

There are a handful of general loggers available:

LoggerDescription

rootLogger

Logs any calls not handled by the Apache ActiveMQ Artemis loggers

org.apache.activemq.artemis.core.server

Logs the core server

org.apache.activemq.artemis.utils

Logs utility calls

org.apache.activemq.artemis.journal

Logs Journal calls

org.apache.activemq.artemis.jms

Logs JMS calls

org.apache.activemq.artemis.integration.bootstrap

Logs bootstrap calls

org.apache.activemq.audit.base

audit log. Disabled by default

org.apache.activemq.audit.resource

resource audit log. Disabled by default

org.apache.activemq.audit.message

message audit log. Disabled by default

1. Configuring a Specific Level for a 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.

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

  1. logger.my_logger_ref.name=org.foo
  2. logger.my_logger_ref.level=TRACE

2. Configuration Reload

Log4J2 has its own configuration file reloading mechanism, which is itself configured via the same log4j2.properties configuration file. To enable reload upon configuration updates, set the monitorInterval config property to the interval in seconds that the file should be monitored for updates, e.g.

  1. # Monitor config file every 5 seconds for updates
  2. monitorInterval = 5

3. Logging in a client application

Firstly, if you want to enable logging on the client side you need to include a logging implementation in your application which supports the the SLF4J facade. Taking Log4J2 as an example logging implementation, since it used by the broker, when using Maven your client and logging dependencies might be e.g.:

  1. <dependency>
  2. <groupId>org.apache.activemq</groupId>
  3. <artifactId>artemis-jms-client</artifactId>
  4. <version>2.34.0</version>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.apache.logging.log4j</groupId>
  8. <artifactId>log4j-slf4j2-impl</artifactId>
  9. <version>2.22.1</version>
  10. </dependency>

The Log4J2 configuration can then be supplied via file called log4j2.properties on the classpath which will then be picked up automatically.

Alternatively, use of a specific configuration file can be configured via system property log4j2.configurationFile, e.g.:

  1. -Dlog4j2.configurationFile=file:///path/to/custom-log4j2-config.properties

The following is an example log4j2.properties for a client application, logging at INFO level to the console and a daily rolling file.

  1. # Log4J 2 configuration
  2. # Monitor config file every X seconds for updates
  3. monitorInterval = 5
  4. rootLogger.level = INFO
  5. rootLogger.appenderRef.console.ref = console
  6. rootLogger.appenderRef.log_file.ref = log_file
  7. logger.activemq.name=org.apache.activemq
  8. logger.activemq.level=INFO
  9. # Console appender
  10. appender.console.type=Console
  11. appender.console.name=console
  12. appender.console.layout.type=PatternLayout
  13. appender.console.layout.pattern=%d %-5level [%logger] %msg%n
  14. # Log file appender
  15. appender.log_file.type = RollingFile
  16. appender.log_file.name = log_file
  17. appender.log_file.fileName = log/application.log
  18. appender.log_file.filePattern = log/application.log.%d{yyyy-MM-dd}
  19. appender.log_file.layout.type = PatternLayout
  20. appender.log_file.layout.pattern = %d %-5level [%logger] %msg%n
  21. appender.log_file.policies.type = Policies
  22. appender.log_file.policies.cron.type = CronTriggeringPolicy
  23. appender.log_file.policies.cron.schedule = 0 0 0 * * ?
  24. appender.log_file.policies.cron.evaluateOnStartup = true

4. Configuring Broker Audit Logging

There are 3 audit loggers that can be enabled separately and audit different types of broker 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.

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 broker log4j2.properties configuration file:

  1. ...
  2. # Audit loggers: to enable change levels from OFF to INFO
  3. logger.audit_base.name = org.apache.activemq.audit.base
  4. logger.audit_base.level = OFF
  5. logger.audit_base.appenderRef.audit_log_file.ref = audit_log_file
  6. logger.audit_base.additivity = false
  7. logger.audit_resource.name = org.apache.activemq.audit.resource
  8. logger.audit_resource.level = OFF
  9. logger.audit_resource.appenderRef.audit_log_file.ref = audit_log_file
  10. logger.audit_resource.additivity = false
  11. logger.audit_message.name = org.apache.activemq.audit.message
  12. logger.audit_message.level = OFF
  13. logger.audit_message.appenderRef.audit_log_file.ref = audit_log_file
  14. logger.audit_message.additivity = false
  15. ...

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

  1. logger.audit_base.level = INFO
  2. ...
  3. logger.audit_resource.level = INFO
  4. ...
  5. logger.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).

5. More on Log4J2 configuration:

For more detail on configuring Log4J 2, see its manual.