title: Log4j JMS appender example
body: <p>I tried to follow <a href="http://activemq.apache.org/how-do-i-use-log4j-jms-appender-with-activemq.html" rel="nofollow">this example</a>, but when I copied this class to my project I failed to run it.</p>
  
  <p>I've no idea how my imports should look like, because eclipse suggests a lot of options. I tried</p>
  
  <pre><code>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.log4j.Logger;
  import org.apache.log4j.spi.LoggingEvent;
  </code></pre>
  
  <p>But I got:</p>
  
  <pre><code>log4j:WARN No appenders could be found for logger (org.apache.activemq.transport.tcp.TcpTransport).
  log4j:WARN Please initialize the log4j system properly.
  log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
  </code></pre>
  
  <p>This tutorial isn't clear for me. Do you know anything with more details (to absolute begginer)? Or maybe you know how to solve my problem with this exception?</p>
  
  <p>EDIT:</p>
  
  <p>log4.properties is exact copy of file in example </p>
  
  <pre><code>log4j.rootLogger=INFO, stdout, jms
  
  ## Be sure that ActiveMQ messages are not logged to 'jms' appender
  log4j.logger.org.apache.activemq=INFO, stdout
  
  log4j.appender.stdout=org.apache.log4j.ConsoleAppender
  log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
  log4j.appender.stdout.layout.ConversionPattern=%d %-5p %c - %m%n
  
  ## Configure 'jms' appender. You'll also need jndi.properties file in order to make it work
  log4j.appender.jms=org.apache.log4j.net.JMSAppender
  log4j.appender.jms.InitialContextFactoryName=org.apache.activemq.jndi.ActiveMQInitialContextFactory
  log4j.appender.jms.ProviderURL=tcp://localhost:61616
  log4j.appender.jms.TopicBindingName=logTopic
  log4j.appender.jms.TopicConnectionFactoryBindingName=ConnectionFactory
  </code></pre>