title: Define logback shutdown hook in Spring Boot
body: <p>I am using AsyncAppender in spring-boot (1.5.3.RELEASE) application. </p>
  
  <p><strong>logback.xml</strong></p>
  
  <pre><code>&lt;appender name="FILE_ASYNC" class="ch.qos.logback.classic.AsyncAppender"&gt;
      &lt;queueSize&gt;5000&lt;/queueSize&gt;
      &lt;discardingThreshold&gt;0&lt;/discardingThreshold&gt;
      &lt;appender-ref ref="FILE" /&gt;
  &lt;/appender&gt;
  </code></pre>
  
  <p>As per logback documentation, </p>
  
  <blockquote>
    <p>Upon application shutdown or redeploy, AsyncAppender must be stopped
    in order to stop and reclaim the worker thread and to flush the
    logging events from the queue.</p>
  </blockquote>
  
  <p><a href="https://logback.qos.ch/manual/appenders.html" rel="noreferrer">https://logback.qos.ch/manual/appenders.html</a></p>
  
  <p>Further it says:</p>
  
  <blockquote>
    <p>In order to avoid interrupting the worker thread under these
    conditions, a shutdown hook can be inserted to the JVM runtime that
    stops the LoggerContext properly after JVM shutdown has been initiated</p>
  </blockquote>
  
  <p>I want to know how to stop AsyncAppender in Spring Boot application. At which place in Spring Boot, should I define shutdown hook?</p>