blob: 33979425065db8be505bed91778ac56e789f8cb1 [file] [log] [blame]
<div class="wiki-content maincontent"><h2>How do I change the logging</h2>
<p>We use <link><page ri:content-title="www.slf4j.org"></page><link-body>slf4j</link-body></link> to log information in the broker client and the broker itself so you can fully configure which logging levels are used and whether to log to files or the console etc. For more information see the <a shape="rect" href="http://logging.apache.org/log4j/docs/manual.html">log4j manual.</a>.</p>
<p>You can disable the ActiveMQ logging by editing the <strong>conf/log4j.properties</strong> file to disable all INFO level logging for activemq by adding this line</p>
<structured-macro ac:macro-id="7662763d-89e4-4530-a809-80b4837b9ac5" ac:name="code" ac:schema-version="1"><plain-text-body>
log4j.logger.org.apache.activemq=WARN
</plain-text-body></structured-macro>
<p>or to disable stdout logging all together change this line</p>
<structured-macro ac:macro-id="329e6a3c-02be-4370-a6d9-ae07172450c1" ac:name="code" ac:schema-version="1"><plain-text-body>
log4j.rootLogger=INFO, stdout, out
</plain-text-body></structured-macro>
<p>to</p>
<structured-macro ac:macro-id="5bfdd37d-318b-4c45-87c0-76fc34ea3276" ac:name="code" ac:schema-version="1"><plain-text-body>
log4j.rootLogger=INFO, out
</plain-text-body></structured-macro>
<h2>How Do I Change the Logging at Runtime? </h2>
<p>The default logging level in ActiveMQ is INFO. This can be seen by starting up the default ActiveMQ binary in a terminal. In doing so, you will see the output shown below: </p>
<structured-macro ac:macro-id="f615105d-e205-4750-b028-693bb3957169" ac:name="code" ac:schema-version="1"><plain-text-body>
$ ./bin/activemq
ACTIVEMQ_HOME: /Users/bsnyder/amq/apache-activemq-5.1.0
ACTIVEMQ_BASE: /Users/bsnyder/amq/apache-activemq-5.1.0
Loading message broker from: xbean:activemq.xml
INFO BrokerService - Using Persistence Adapter: AMQPersistenceAdapter(/Users/bsnyder/amq/apache-activemq-5.1.0/data)
INFO BrokerService - ActiveMQ 5.1.0 JMS Message Broker (localhost) is starting
INFO BrokerService - For help or more information please see: http://activemq.apache.org/
INFO AMQPersistenceAdapter - AMQStore starting using directory: /Users/bsnyder/amq/apache-activemq-5.1.0/data
INFO KahaStore - Kaha Store using data directory /Users/bsnyder/amq/apache-activemq-5.1.0/data/kr-store/state
INFO AMQPersistenceAdapter - Active data files: []
INFO KahaStore - Kaha Store using data directory /Users/bsnyder/amq/apache-activemq-5.1.0/data/kr-store/data
INFO TransportServerThreadSupport - Listening for connections at: tcp://mongoose.local:61616
INFO TransportConnector - Connector openwire Started
INFO TransportServerThreadSupport - Listening for connections at: ssl://mongoose.local:61617
INFO TransportConnector - Connector ssl Started
INFO TransportServerThreadSupport - Listening for connections at: stomp://mongoose.local:61613
INFO TransportConnector - Connector stomp Started
INFO TransportServerThreadSupport - Listening for connections at: xmpp://mongoose.local:61222
INFO TransportConnector - Connector xmpp Started
INFO NetworkConnector - Network Connector default-nc Started
INFO BrokerService - ActiveMQ JMS Message Broker (localhost, ID:mongoose.local-56138-1224025139259-0:0) started
INFO log - Logging to org.slf4j.impl.JCLLoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog
INFO log - jetty-6.1.9
INFO WebConsoleStarter - ActiveMQ WebConsole initialized.
INFO /admin - Initializing Spring FrameworkServlet 'dispatcher'
INFO log - ActiveMQ Console at http://0.0.0.0:8161/admin
INFO log - ActiveMQ Web Demos at http://0.0.0.0:8161/demo
INFO log - RESTful file access application at http://0.0.0.0:8161/fileserver
INFO log - Started SelectChannelConnector@0.0.0.0:8161
INFO FailoverTransport - Successfully connected to tcp://localhost:61616
</plain-text-body></structured-macro>
<p>But stopping ActiveMQ to change the logging level is not always feasible. There are many cases where the logging level and other configuration details may need to be changed at runtime. Using a JMX tool such as jconsole, the logging configuration file can be changed and reloaded without shutting down ActiveMQ. </p>
<p>To change the ActiveMQ logging level from INFO to DEBUG while ActiveMQ is running, start up jconsole, point to the ActiveMQ instance and navigate to the Broker object's Operations tab as shown below: </p>
<p><image><attachment ri:filename="reloadLog4jProperties1.png"></attachment></image> </p>
<p>To enable debug level logging in ActiveMQ, edit the <code>conf/log4j.properties</code> file that is part of the ActiveMQ binary distribution to disable INFO level logging and enable DEBUG level logging from this: </p>
<structured-macro ac:macro-id="69566c36-e040-447f-b6a7-c3b605598339" ac:name="code" ac:schema-version="1"><plain-text-body>
log4j.rootLogger=INFO, stdout, out
log4j.logger.org.apache.activemq.spring=WARN
log4j.logger.org.springframework=WARN
log4j.logger.org.apache.xbean.spring=WARN
# When debugging or reporting problems to the ActiveMQ team,
# comment out the above lines and uncomment the next.
#log4j.rootLogger=DEBUG, out, stdout
</plain-text-body></structured-macro>
<p>to this: </p>
<structured-macro ac:macro-id="3d1df33e-61ff-437d-8f1f-6f8966109da9" ac:name="code" ac:schema-version="1"><plain-text-body>
#log4j.rootLogger=INFO, stdout, out
log4j.logger.org.apache.activemq.spring=WARN
log4j.logger.org.springframework=WARN
log4j.logger.org.apache.xbean.spring=WARN
# When debugging or reporting problems to the ActiveMQ team,
# comment out the above lines and uncomment the next.
log4j.rootLogger=DEBUG, out, stdout
</plain-text-body></structured-macro>
<p>Notice that the line <code>log4j.rootLogger=INFO, stdout, out</code> has been commented out and the line <code>log4j.rootLogger=DEBUG, out, stdout</code> has been uncommented. Save this change and then, in jconsole, click the button named <strong>reloadLog4jProperties</strong> as shown below: </p>
<p><image><attachment ri:filename="reloadLog4jProperties2.png"></attachment></image> </p>
<p>After clicking the <strong>reloadLog4jProperties</strong> button, the dialog pops up stating, 'Method successfully invoked'. This just lets you know that the <code>reloadLog4jProperties</code> method was invoked to reload the <code>conf/log4j.properties</code> file. Now notice in the terminal where ActiveMQ is running that the logging that is being output is now DEBUG: </p>
<structured-macro ac:macro-id="4254803e-e312-467b-819b-c303a0be9254" ac:name="code" ac:schema-version="1"><plain-text-body>
INFO WebConsoleStarter - ActiveMQ WebConsole initialized.
INFO /admin - Initializing Spring FrameworkServlet 'dispatcher'
INFO log - ActiveMQ Console at http://0.0.0.0:8161/admin
INFO log - ActiveMQ Web Demos at http://0.0.0.0:8161/demo
INFO log - RESTful file access application at http://0.0.0.0:8161/fileserver
INFO log - Started SelectChannelConnector@0.0.0.0:8161
INFO FailoverTransport - Successfully connected to tcp://localhost:61616
DEBUG InactivityMonitor - 10000 ms elapsed since last write check.
DEBUG InactivityMonitor - 10000 ms elapsed since last write check.
DEBUG AbstractRegion - Removing consumer: ID:mongoose.local-56517-1224026019987-0:0:-1:1
DEBUG AbstractRegion - Removing consumer: ID:mongoose.local-56511-1224026011897-0:0:1:1
DEBUG TransportConnection - Stopping connection: /127.0.0.1:56518
DEBUG TcpTransport - Stopping transport tcp:///127.0.0.1:56518
DEBUG TransportConnection - Stopped connection: /127.0.0.1:56518
DEBUG TransportConnection - Connection Stopped: /127.0.0.1:56518
DEBUG AbstractRegion - Removing consumer: ID:mongoose.local-56511-1224026011897-0:0:-1:1
DEBUG TransportConnection - Stopping connection: /127.0.0.1:56512
DEBUG TcpTransport - Stopping transport tcp:///127.0.0.1:56512
DEBUG TransportConnection - Stopped connection: /127.0.0.1:56512
DEBUG TransportConnection - Connection Stopped: /127.0.0.1:56512
DEBUG InactivityMonitor - 9999 ms elapsed since last write check.
DEBUG InactivityMonitor - 10000 ms elapsed since last write check.
DEBUG InactivityMonitor - 29999 ms elapsed since last read check.
</plain-text-body></structured-macro>
<p>Disabling DEBUG level logging and enabling INFO level logging is done by editing the <code>log4j.properties</code> file and clicking the <strong>reloadLog4jProperties</strong> button again. </p></div>