title: Spring Boot + logback + autowire
body: <p>I'm running a Spring Boot application that uses logback. The idea is to have the log messages be sent to a RabbitMQ server. To accomplish this, I created an appender that extends ch.qos.logback.core.AppenderBase. </p>
  
  <p>Here is my logback-spring.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
      &lt;appender name="messaging" class="com.foo.logging.appender.MessagingAppenderLogback" /&gt;
      &lt;root level="info"&gt;
          &lt;appender-ref ref="messaging" /&gt;
      &lt;/root&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>All is well. However, in MessagingAppenderLogback, RabbitTemplate which I wish to use to send the message is null.</p>
  
  <pre><code>@Component
  public class MessagingAppenderLogback extends AppenderBase&lt;ILoggingEvent&gt; {
      @Autowired
      RabbitTemplate rabbitTemplate;
  
      public MessagingAppenderLogback(){ }
  
      @Override
      protected void append(ILoggingEvent event) {
          System.out.println("  MessagingAppenderLogback#append w/ event " + event);
          // rabbitTemplate.convertAndSend(event);
      }   
  }
  </code></pre>
  
  <p>Per the <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html" rel="nofollow noreferrer">documentation</a>, I know that "The logging system is initialized early in the application ..."</p>
  
  <p>I'd like to know what I have to do to have rabbitTemplate available in my appender.</p>