Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

JMSAppender and logging

Posts: 7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Members,

I am trying to put a logging mechanism in place using commons logging and log4j. I have managed to configure for Console and FileAppender. However, I am having difficulty in making JMSAppender work on my local box. Please find below log4j properties file and test code.

Log4j properties:

log4j.appender.JMSAPPENDER =
log4j.appender.JMSAPPENDER.Threshold = DEBUG
log4j.appender.JMSAPPENDER.InitialContextFactoryName = org.apache.activemq.jndi.ActiveMQInitialContextFactory
log4j.appender.JMSAPPENDER.ProviderURL = tcp://localhost:61616
log4j.appender.JMSAPPENDER.TopicBindingName = logTopic
log4j.appender.JMSAPPENDER.TopicConnectionFactoryBindingName = ConnectionFactory

JAVA Class:

package test;
import javax.jms.Connection;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Session;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQObjectMessage;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.spi.LoggingEvent;

public class Log4jJMSAppenderExample implements MessageListener {

private static final Log logger = LogFactory.getLog("Log4jJMSAppenderExample.class");
public Log4jJMSAppenderExample() throws Exception {

// create a logTopic topic consumer
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
Connection conn = factory.createConnection();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = sess.createConsumer(sess.createTopic("logTopic"));
consumer.setMessageListener((MessageListener) this);

// log a message"Test log");

// clean up

public static void main(String[] args) throws Exception {
new Log4jJMSAppenderExample();

public void onMessage(Message message) {
try {
// receive log event in your consumer
LoggingEvent event = (LoggingEvent)((ActiveMQObjectMessage)message).getObject();
System.out.println("Received log [" + event.getLevel() + "]: "+ event.getMessage());
} catch (Exception e) {


I am getting below errors. Please can somebody help.

log4j:ERROR Error while activating options for appender named [JMSAPPENDER].
javax.jms.JMSException: Wire format negotiation timeout: peer did not send his wire format.
at org.apache.activemq.util.JMSExceptionSupport.create(
at org.apache.activemq.ActiveMQConnection.syncSendPacket(
at org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(
at org.apache.activemq.ActiveMQConnection.createSession(
at org.apache.activemq.ActiveMQConnection.createTopicSession(
at Source)
at org.apache.log4j.config.PropertySetter.activate(
at org.apache.log4j.config.PropertySetter.setProperties(
at org.apache.log4j.config.PropertySetter.setProperties(
at org.apache.log4j.PropertyConfigurator.parseAppender(
at org.apache.log4j.PropertyConfigurator.parseCategory(
at org.apache.log4j.PropertyConfigurator.configureRootCategory(
at org.apache.log4j.PropertyConfigurator.doConfigure(
at org.apache.log4j.PropertyConfigurator.doConfigure(
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(
at org.apache.log4j.LogManager.<clinit>(
at org.apache.log4j.Logger.getLogger(
at org.apache.commons.logging.impl.Log4JLogger.getLogger(
at org.apache.commons.logging.impl.Log4JLogger.<init>(
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.lang.reflect.Constructor.newInstance(
at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(
at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(
at org.apache.commons.logging.LogFactory.getLog(
at test.Log4jJMSAppenderExample.<clinit>(
Caused by: Wire format negotiation timeout: peer did not send his wire format.
at org.apache.activemq.transport.WireFormatNegotiator.oneway(
at org.apache.activemq.transport.MutexTransport.oneway(
at org.apache.activemq.transport.ResponseCorrelator.asyncRequest(
at org.apache.activemq.transport.ResponseCorrelator.request(
at org.apache.activemq.ActiveMQConnection.syncSendPacket(
... 27 more
Ranch Hand
Posts: 198
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the link below
Active MQ - Log4j JMS Appender

Hope that resolves your issue.

Aditya Yagnik
Posts: 7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Prabhakar. I have managed to create a topic. Next task is to configure chainsaw to read the log.

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1- One possibility could be that you are connecting to a wrong host:port this link can explain this issue
2- make sure activemq-all-5.5.1.jar is not included twice on your classpath. if it is already loaded by tomcat from its lib directory then remove it from your war or vice versa.
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic