title: Logback JMSAppender not cleaning up connections with ActiveMQ
body: <p>i am trying to use JMSAppenders in Logback. I tried out a simple app to do that and have successfully sent logs into queues in ActiveMQ. </p>
  
  <pre><code>package test;
  
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
  public class LoggerTest {
      public static void main(String[] args) {
          Logger logger = LoggerFactory.getLogger("test");
          logger.debug("debug");
          logger.info("info");
          logger.warn("warn");
          logger.error("error", new Exception(""));
  
  
      }
  }
  </code></pre>
  
  <p>Everything runs fine but this application wont terminate even after all the statements in main have executed. </p>
  
  <p>After some poking around I noticed that after the main thread ends  there were two non daemon threads active 
  ActiveMQ Transport and DestroyJavaVM
  I believe this DestoryJavaVM thread came into being after main thread exited.</p>
  
  <p>I think this has something to do with sessions/connections not closing. If I terminate the broker, the app also exits. </p>
  
  <p>There is a <code>stop()</code> method in JMSQueueAppender that closes sessions but it seems its never called, apparently <code>stop</code> method is not called for other appenders as well -- i tried it on RollingFileAppender. </p>
  
  <p>I tried the same setup with HornetQ and it works fine but not with activeMQ</p>
  
  <p>I am using slf4j 1.6.4, logback 1.0.0 and activemq 5.5.0</p>
  
  <p>Heres the logback configuration </p>
  
  <p>
  </p>
  
  <pre><code>&lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"&gt;
      &lt;!-- encoders are by default assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder --&gt;
      &lt;encoder&gt;
          &lt;pattern&gt;%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
          &lt;/pattern&gt;
      &lt;/encoder&gt;
  &lt;/appender&gt;
  
  
  &lt;appender name="Queue" class="ch.qos.logback.classic.net.JMSQueueAppender"&gt;
      &lt;InitialContextFactoryName&gt;
          org.apache.activemq.jndi.ActiveMQInitialContextFactory
      &lt;/InitialContextFactoryName&gt;
      &lt;ProviderURL&gt;tcp://localhost:61616&lt;/ProviderURL&gt;
      &lt;QueueConnectionFactoryBindingName&gt;
          ConnectionFactory
      &lt;/QueueConnectionFactoryBindingName&gt;
      &lt;QueueBindingName&gt;dynamicQueues/MyQueue&lt;/QueueBindingName&gt;
  &lt;/appender&gt;
  
  
  &lt;root level="debug"&gt;
      &lt;appender-ref ref="Queue" /&gt;
      &lt;appender-ref ref="STDOUT" /&gt;
  &lt;/root&gt;
  
  &lt;logger name="org.apache.activemq" additivity="false" level="DEBUG"&gt;
      &lt;appender-ref ref="STDOUT" /&gt;
  &lt;/logger&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>and pom</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;LoggerTest&lt;/groupId&gt;
      &lt;artifactId&gt;LoggerTest&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
              &lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
              &lt;version&gt;1.0.0&lt;/version&gt;
  &lt;!--            &lt;scope&gt;runtime&lt;/scope&gt; --&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
              &lt;artifactId&gt;logback-core&lt;/artifactId&gt;
              &lt;version&gt;1.0.0&lt;/version&gt;
  &lt;!--            &lt;scope&gt;runtime&lt;/scope&gt; --&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;version&gt;1.6.4&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
              &lt;artifactId&gt;activemq-core&lt;/artifactId&gt;
              &lt;version&gt;5.5.0&lt;/version&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
                      &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Can anybody point out whats wrong with this setup. Thanks in advance</p>