title: ActiveMQ: How to avoid Debug messages being send to log4j Console?
body: <p>I am sending messages to an ActiveMQ message broker (version 5.15.10) by the following code:</p>
  
  <pre><code>classConstructor() {
      connection = (ActiveMQConnection) connectionFactory.createConnection(ActiveMqConfig.activeMqUser,
                  ActiveMqConfig.activeMqUser);
  [...]
  }
  
  public void sendStringMessage(String messageText, String queueName) {
      try {
          connection.start();
          session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
          destination = _session.createQueue(queueName);
          producer = _session.createProducer(_destination);
          producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
          producer.setTimeToLive(30000);
          producer.setPriority(0);
          TextMessage message = _session.createTextMessage(messageText);
          producer.send(message);
          session.close();
          connection.close();
      } catch (Exception ex) {
          MessageLogger.logError(getClass(), ex);
      }
  }
  </code></pre>
  
  <p>This works well, but I get DEBUG messages from ActiveMQ which cause a heap out of memory error after a while. These messages look like this:</p>
  
  <pre><code>11:08:51.477 [ForkJoinPool.commonPool-worker-9] DEBUG org.apache.activemq.transport.WireFormatNegotiator - Sending: WireFormatInfo { version=12, properties={StackTraceEnabled=true, PlatformDetails=Java, CacheEnabled=true, Host=vmla032.acc.gsi.de, TcpNoDelayEnabled=true, SizePrefixDisabled=false, CacheSize=1024, ProviderName=ActiveMQ, TightEncodingEnabled=true, MaxFrameSize=9223372036854775807, MaxInactivityDuration=30000, MaxInactivityDurationInitalDelay=10000, ProviderVersion=5.15.10}, magic=[A,c,t,i,v,e,M,Q]}
  11:08:51.477 [ActiveMQ Transport: tcp://myUrl:61616@47126] DEBUG org.apache.activemq.transport.InactivityMonitor - Using min of local: WireFormatInfo { version=12, properties={StackTraceEnabled=true, PlatformDetails=Java, CacheEnabled=true, Host=vmla032.acc.gsi.de, TcpNoDelayEnabled=true, SizePrefixDisabled=false, CacheSize=1024, ProviderName=ActiveMQ, TightEncodingEnabled=true, MaxFrameSize=9223372036854775807, MaxInactivityDuration=30000, MaxInactivityDurationInitalDelay=10000, ProviderVersion=5.15.10}, magic=[A,c,t,i,v,e,M,Q]} and remote: WireFormatInfo { version=12, properties={TcpNoDelayEnabled=true, SizePrefixDisabled=false, CacheSize=1024, ProviderName=ActiveMQ, StackTraceEnabled=true, PlatformDetails=Java, CacheEnabled=true, TightEncodingEnabled=true, MaxFrameSize=104857600, MaxInactivityDuration=30000, MaxInactivityDurationInitalDelay=10000, ProviderVersion=5.15.10}, magic=[A,c,t,i,v,e,M,Q]}
  11:08:51.478 [ActiveMQ Transport: tcp://myUrl:61616@47126] DEBUG org.apache.activemq.transport.WireFormatNegotiator - Received WireFormat: WireFormatInfo { version=12, properties={TcpNoDelayEnabled=true, SizePrefixDisabled=false, CacheSize=1024, ProviderName=ActiveMQ, StackTraceEnabled=true, PlatformDetails=Java, CacheEnabled=true, TightEncodingEnabled=true, MaxFrameSize=104857600, MaxInactivityDuration=30000, MaxInactivityDurationInitalDelay=10000, ProviderVersion=5.15.10}, magic=[A,c,t,i,v,e,M,Q]}
  11:08:51.478 [ActiveMQ Transport: tcp://myUrl:61616@47126] DEBUG org.apache.activemq.transport.WireFormatNegotiator - tcp://myUrl:61616@47126 before negotiation: OpenWireFormat{version=12, cacheEnabled=false, stackTraceEnabled=false, tightEncodingEnabled=false, sizePrefixDisabled=false, maxFrameSize=9223372036854775807}
  11:08:51.478 [ActiveMQ Transport: tcp://myUrl:61616@47126] DEBUG org.apache.activemq.transport.WireFormatNegotiator - tcp://myUrl:61616@47126 after negotiation: OpenWireFormat{version=12, cacheEnabled=true, stackTraceEnabled=true, tightEncodingEnabled=true, sizePrefixDisabled=false, maxFrameSize=104857600}
  11:08:51.488 [ForkJoinPool.commonPool-worker-9] DEBUG org.apache.activemq.util.ThreadPoolUtils - Shutdown of ExecutorService: java.util.concurrent.ThreadPoolExecutor@370c55d1[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0] is shutdown: true and terminated: true took: 0.000 seconds.
  11:08:51.488 [ForkJoinPool.commonPool-worker-9] DEBUG org.apache.activemq.util.ThreadPoolUtils - Shutdown of ExecutorService: java.util.concurrent.ThreadPoolExecutor@4cd7acb5[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0] is shutdown: true and terminated: true took: 0.000 seconds.
  11:08:51.488 [ForkJoinPool.commonPool-worker-9] DEBUG org.apache.activemq.transport.tcp.TcpTransport - Stopping transport tcp://myUrl:61616@47126
  11:08:51.489 [ForkJoinPool.commonPool-worker-9] DEBUG org.apache.activemq.thread.TaskRunnerFactory - Initialized TaskRunnerFactory[ActiveMQ Task] using ExecutorService: java.util.concurrent.ThreadPoolExecutor@6eac26a0[Running, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0]
  11:08:51.489 [ActiveMQ Task-1] DEBUG org.apache.activemq.transport.tcp.TcpTransport - Closed socket Socket[addr=myUrl,port=61616,localport=47126]
  11:08:51.489 [ForkJoinPool.commonPool-worker-9] DEBUG org.apache.activemq.util.ThreadPoolUtils - Forcing shutdown of ExecutorService: java.util.concurrent.ThreadPoolExecutor@6eac26a0[Running, pool size = 1, active threads = 0, queued tasks = 0, completed tasks = 1]
  11:08:51.489 [ForkJoinPool.commonPool-worker-9] INFO de.gsi.sdbe.playground.wgeithner.archiving.data.extractor.QueryPerformer - 
  </code></pre>
  
  <p>My log4j.properties look as follows:</p>
  
  <pre><code>&lt;Configuration status="error" name="sbde" packages="log4j.package.log4j2"&gt;
      &lt;Properties&gt;
          &lt;Property name="messagePattern"&gt;%5p [%d{dd MMM yyyy HH:mm:ss,SSS}] (%F) - %m%n&lt;/Property&gt;
      &lt;/Properties&gt;
  
      &lt;Appenders&gt;
          &lt;Console name="Console" target="SYSTEM_OUT"&gt;
              &lt;PatternLayout pattern="${messagePattern}" /&gt;
          &lt;/Console&gt;
      &lt;/Appenders&gt;
  
      &lt;Loggers&gt;
          &lt;Root level="error"&gt;
              &lt;AppenderRef ref="Console" level="error" /&gt;
          &lt;/Root&gt;
      &lt;/Loggers&gt;
  
  &lt;/Configuration&gt;
  </code></pre>
  
  <p>In my activeMQ server I already edited log4j.properties already:</p>
  
  <pre><code># log4j.rootLogger=INFO, console, logfile
  log4j.rootLogger=INFO, out
  log4j.logger.org.apache.activemq.spring=WARN
  log4j.logger.org.apache.activemq.web.handler=WARN
  log4j.logger.org.springframework=WARN
  log4j.logger.org.apache.xbean=WARN
  log4j.logger.org.apache.camel=INFO
  log4j.logger.org.eclipse.jetty=WARN
  
  # When debugging or reporting problems to the ActiveMQ team,
  # comment out the above lines and uncomment the next.
  
  #log4j.rootLogger=DEBUG, logfile, console
  
  # Or for more fine grained debug logging uncomment one of these
  #log4j.logger.org.apache.activemq=DEBUG
  #log4j.logger.org.apache.camel=DEBUG
  
  # Console appender
  log4j.appender.console=org.apache.log4j.ConsoleAppender
  log4j.appender.console.layout=org.apache.log4j.PatternLayout
  log4j.appender.console.layout.ConversionPattern=%5p | %m%n
  log4j.appender.console.threshold=WARN
  
  # File appender
  log4j.appender.logfile=org.apache.log4j.RollingFileAppender
  log4j.appender.logfile.file=${activemq.data}/activemq.log
  log4j.appender.logfile.maxFileSize=1024KB
  log4j.appender.logfile.maxBackupIndex=5
  log4j.appender.logfile.append=true
  log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
  log4j.appender.logfile.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n
  # use some of the following patterns to see MDC logging data
  #
  # %X{activemq.broker}
  # %X{activemq.connector}
  # %X{activemq.destination}
  #
  # e.g.
  #
  # log4j.appender.logfile.layout.ConversionPattern=%d | %-20.20X{activemq.connector} | %-5p | %m | %c | %t%n
  
  log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer
  
  ###########
  # Audit log
  ###########
  
  log4j.additivity.org.apache.activemq.audit=false
  # log4j.logger.org.apache.activemq.audit=INFO, audit
  
  log4j.appender.audit=org.apache.log4j.RollingFileAppender
  log4j.appender.audit.file=${activemq.data}/audit.log
  log4j.appender.audit.maxFileSize=1024KB
  log4j.appender.audit.maxBackupIndex=5
  </code></pre>
  
  <p>How do I get rid of these messages? Any idea welcome</p>