如何为ActiveMQ Artemis特定日志器开TRACE及配置分流日志
Let's break down your two ActiveMQ Artemis logging questions with clear, actionable steps:
1. Enabling TRACE-level logging for a specific logger in ActiveMQ Artemis
ActiveMQ Artemis uses Java Util Logging (JUL) under the hood, so all logging configuration lives in the etc/logging.properties file in your Artemis instance directory. Here's how to target a specific logger:
- Open up
etc/logging.propertiesin a text editor. - Locate (or add) the line for your target logger. The format is
[logger-name].level = TRACE. For example, if you wanted to target the divert implementation class (which ties into your second question), you'd add:org.apache.activemq.artemis.core.server.impl.DivertImpl.level = TRACE - Critical check: Make sure the handler responsible for writing logs (like the FileHandler for
artemis.log) is set to accept TRACE-level logs. If the handler's level is set toINFOor higher, it will filter out TRACE messages. Update it like this:java.util.logging.FileHandler.level = TRACE - Save the file and restart your ActiveMQ Artemis server for the changes to take effect.
2. Configuring
logging.properties to log divert activity to artemis.log Since you specifically mentioned targeting org.apache.activemq.artemis.core.server.impl.DivertImpl with TRACE level, here's the step-by-step to ensure those logs end up in artemis.log:
- First, confirm your
logging.propertiesalready has a FileHandler configured forartemis.log(this is usually default, but double-check):handlers = java.util.logging.FileHandler, java.util.logging.ConsoleHandler java.util.logging.FileHandler.level = INFO java.util.logging.FileHandler.formatter = org.apache.activemq.artemis.utils.ActiveMQFormatter java.util.logging.FileHandler.pattern = ${artemis.instance}/log/artemis.log - Update the FileHandler's level to
TRACEso it can capture the detailed divert logs:java.util.logging.FileHandler.level = TRACE - Add the specific logger configuration for the divert implementation to enable TRACE logging:
org.apache.activemq.artemis.core.server.impl.DivertImpl.level = TRACE - Optional: If you don't want these TRACE logs cluttering your console, you can disable parent handler inheritance for this logger so logs only go to
artemis.log:org.apache.activemq.artemis.core.server.impl.DivertImpl.useParentHandlers = false org.apache.activemq.artemis.core.server.impl.DivertImpl.handlers = java.util.logging.FileHandler - Save the configuration file, restart Artemis, and you'll start seeing detailed TRACE logs from the divert implementation in
artemis.log.
内容的提问来源于stack exchange,提问作者ZiggyStardust
相关产品推荐
相关产品推荐

