Log4j JMS appender can be used to send your log messages to JMS broker. To use ActiveMQ as a destination of your messages, you need to configure JMS appender properly. The code sample below shows example configuration:

The important thing is not to send ActiveMQ logs to JMS appender, as it can cause errors since the broker will want to log before the connection is established. You will also need a JNDI configuration, so that appender can find appropriate topic to send log messages to. The example jndi.properties file can look like this:

Finally, you can subscribe to the topic and listen for log messages:

Note that appender send logging event wrapped in an object message, so you can extract information such as logger name, level and of course the message.

Starting with ActiveMQ 5.3, this example is included in the standard distribution. You can run it by executing

inside example/ folder. You can expect the following output as a result:

© 2004-2011 The Apache Software Foundation.
Apache ActiveMQ, ActiveMQ, Apache, the Apache feather logo, and the Apache ActiveMQ project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram