| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <meta name="generator" content="Asciidoctor 2.0.18"> |
| <link rel="icon" type="image/png" href="images/favicon.png"> |
| <title>Logging</title> |
| <link rel="stylesheet" href="css/asciidoctor.css"> |
| <link rel="stylesheet" href="css/font-awesome.css"> |
| <link rel="stylesheet" href="css/rouge-github.css"> |
| </head> |
| <body class="book toc2 toc-left"> |
| <div id="header"> |
| <h1>Logging</h1> |
| <div id="toc" class="toc2"> |
| <div id="toctitle"><a href="index.html">User Manual for 2.32.0</a></div> |
| <ul class="sectlevel1"> |
| <li><a href="#configuring-a-specific-level-for-a-logger">1. Configuring a Specific Level for a Logger</a></li> |
| <li><a href="#configuration-reload">2. Configuration Reload</a></li> |
| <li><a href="#logging-in-a-client-application">3. Logging in a client application</a></li> |
| <li><a href="#configuring-broker-audit-logging">4. Configuring Broker Audit Logging</a></li> |
| <li><a href="#more-on-log4j2-configuration">5. More on Log4J2 configuration:</a></li> |
| </ul> |
| </div> |
| </div> |
| <div id="content"> |
| <div id="preamble"> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Apache ActiveMQ Artemis uses the <a href="https://www.slf4j.org/">SLF4J</a> logging facade for logging, with the broker assembly providing <a href="https://logging.apache.org/log4j/2.x/manual/">Log4J 2</a> as the logging implementation. |
| This is configurable via the <code>log4j2.properties</code> file found in the broker instance <code>etc</code> directory, which is configured by default to log to both the console and to a file.</p> |
| </div> |
| <div class="paragraph"> |
| <p>There are a handful of general loggers available:</p> |
| </div> |
| <table class="tableblock frame-all grid-all stretch"> |
| <colgroup> |
| <col style="width: 50%;"> |
| <col style="width: 50%;"> |
| </colgroup> |
| <thead> |
| <tr> |
| <th class="tableblock halign-left valign-top">Logger</th> |
| <th class="tableblock halign-left valign-top">Description</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">rootLogger</p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">Logs any calls not handled by the Apache ActiveMQ Artemis loggers</p></td> |
| </tr> |
| <tr> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">org.apache.activemq.artemis.core.server</p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">Logs the core server</p></td> |
| </tr> |
| <tr> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">org.apache.activemq.artemis.utils</p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">Logs utility calls</p></td> |
| </tr> |
| <tr> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">org.apache.activemq.artemis.journal</p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">Logs Journal calls</p></td> |
| </tr> |
| <tr> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">org.apache.activemq.artemis.jms</p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">Logs JMS calls</p></td> |
| </tr> |
| <tr> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">org.apache.activemq.artemis.integration.bootstrap</p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">Logs bootstrap calls</p></td> |
| </tr> |
| <tr> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">org.apache.activemq.audit.base</p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">audit log. |
| Disabled by default</p></td> |
| </tr> |
| <tr> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">org.apache.activemq.audit.resource</p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">resource audit log. |
| Disabled by default</p></td> |
| </tr> |
| <tr> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">org.apache.activemq.audit.message</p></td> |
| <td class="tableblock halign-left valign-top"><p class="tableblock">message audit log. |
| Disabled by default</p></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="configuring-a-specific-level-for-a-logger"><a class="anchor" href="#configuring-a-specific-level-for-a-logger"></a><a class="link" href="#configuring-a-specific-level-for-a-logger">1. Configuring a Specific Level for a Logger</a></h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>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 <code>org.foo</code>.</p> |
| </div> |
| <div class="paragraph"> |
| <p>Then you need to configure the logging level for the <code>org.foo</code> logger to <code>TRACE</code>, e.g.:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="nowrap">logger.my_logger_ref.name=org.foo |
| logger.my_logger_ref.level=TRACE</pre> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="configuration-reload"><a class="anchor" href="#configuration-reload"></a><a class="link" href="#configuration-reload">2. Configuration Reload</a></h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>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 <code>monitorInterval</code> config property to the interval in seconds that the file should be monitored for updates, e.g.</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="nowrap"># Monitor config file every 5 seconds for updates |
| monitorInterval = 5</pre> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="logging-in-a-client-application"><a class="anchor" href="#logging-in-a-client-application"></a><a class="link" href="#logging-in-a-client-application">3. Logging in a client application</a></h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>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.:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="rouge highlight nowrap"><code data-lang="xml"><span class="nt"><dependency></span> |
| <span class="nt"><groupId></span>org.apache.activemq<span class="nt"></groupId></span> |
| <span class="nt"><artifactId></span>artemis-jms-client<span class="nt"></artifactId></span> |
| <span class="nt"><version></span>2.32.0<span class="nt"></version></span> |
| <span class="nt"></dependency></span> |
| <span class="nt"><dependency></span> |
| <span class="nt"><groupId></span>org.apache.logging.log4j<span class="nt"></groupId></span> |
| <span class="nt"><artifactId></span>log4j-slf4j2-impl<span class="nt"></artifactId></span> |
| <span class="nt"><version></span>2.21.1<span class="nt"></version></span> |
| <span class="nt"></dependency></span></code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>The Log4J2 configuration can then be supplied via file called <code>log4j2.properties</code> on the classpath which will then be picked up automatically.</p> |
| </div> |
| <div class="paragraph"> |
| <p>Alternatively, use of a specific configuration file can be configured via system property <code>log4j2.configurationFile</code>, e.g.:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="nowrap">-Dlog4j2.configurationFile=file:///path/to/custom-log4j2-config.properties</pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>The following is an example <code>log4j2.properties</code> for a client application, logging at INFO level to the console and a daily rolling file.</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="nowrap"># Log4J 2 configuration |
| |
| # Monitor config file every X seconds for updates |
| monitorInterval = 5 |
| |
| rootLogger.level = INFO |
| rootLogger.appenderRef.console.ref = console |
| rootLogger.appenderRef.log_file.ref = log_file |
| |
| logger.activemq.name=org.apache.activemq |
| logger.activemq.level=INFO |
| |
| # Console appender |
| appender.console.type=Console |
| appender.console.name=console |
| appender.console.layout.type=PatternLayout |
| appender.console.layout.pattern=%d %-5level [%logger] %msg%n |
| |
| # Log file appender |
| appender.log_file.type = RollingFile |
| appender.log_file.name = log_file |
| appender.log_file.fileName = log/application.log |
| appender.log_file.filePattern = log/application.log.%d{yyyy-MM-dd} |
| appender.log_file.layout.type = PatternLayout |
| appender.log_file.layout.pattern = %d %-5level [%logger] %msg%n |
| appender.log_file.policies.type = Policies |
| appender.log_file.policies.cron.type = CronTriggeringPolicy |
| appender.log_file.policies.cron.schedule = 0 0 0 * * ? |
| appender.log_file.policies.cron.evaluateOnStartup = true</pre> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="configuring-broker-audit-logging"><a class="anchor" href="#configuring-broker-audit-logging"></a><a class="link" href="#configuring-broker-audit-logging">4. Configuring Broker Audit Logging</a></h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>There are 3 audit loggers that can be enabled separately and audit different types of broker events, these are:</p> |
| </div> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p><strong>base</strong>: This is a highly verbose logger that will capture most events that occur on JMX beans.</p> |
| </li> |
| <li> |
| <p><strong>resource</strong>: 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.</p> |
| </li> |
| <li> |
| <p><strong>message</strong>: This logs the production and consumption of messages.</p> |
| </li> |
| </ol> |
| </div> |
| <div class="admonitionblock note"> |
| <table> |
| <tr> |
| <td class="icon"> |
| <i class="fa icon-note" title="Note"></i> |
| </td> |
| <td class="content"> |
| <div class="paragraph"> |
| <p>All extra logging will negatively impact performance. |
| Whether or not the performance impact is "too much" will depend on your use-case.</p> |
| </div> |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div class="paragraph"> |
| <p>These three audit loggers are disabled by default in the broker <code>log4j2.properties</code> configuration file:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="nowrap">... |
| # Audit loggers: to enable change levels from OFF to INFO |
| logger.audit_base.name = org.apache.activemq.audit.base |
| logger.audit_base.level = OFF |
| logger.audit_base.appenderRef.audit_log_file.ref = audit_log_file |
| logger.audit_base.additivity = false |
| |
| logger.audit_resource.name = org.apache.activemq.audit.resource |
| logger.audit_resource.level = OFF |
| logger.audit_resource.appenderRef.audit_log_file.ref = audit_log_file |
| logger.audit_resource.additivity = false |
| |
| logger.audit_message.name = org.apache.activemq.audit.message |
| logger.audit_message.level = OFF |
| logger.audit_message.appenderRef.audit_log_file.ref = audit_log_file |
| logger.audit_message.additivity = false |
| ...</pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>To <em>enable</em> the audit log change the level to <code>INFO</code>, like this:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="nowrap">logger.audit_base.level = INFO |
| ... |
| logger.audit_resource.level = INFO |
| ... |
| logger.audit_message.level = INFO</pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>The 3 audit loggers can be disable/enabled separately.</p> |
| </div> |
| <div class="paragraph"> |
| <p>Once enabled, all audit records are written into a separate log file (by default <code>audit.log</code>).</p> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="more-on-log4j2-configuration"><a class="anchor" href="#more-on-log4j2-configuration"></a><a class="link" href="#more-on-log4j2-configuration">5. More on Log4J2 configuration:</a></h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>For more detail on configuring Log4J 2, see its <a href="https://logging.apache.org/log4j/2.x/manual/">manual</a>.</p> |
| </div> |
| </div> |
| </div> |
| </div> |
| </body> |
| </html> |