title: Logback and SMTPAppender Issue
body: <p>I added Logback to my Spring Boot project and it works when writing in files or standard output. Now I would like to send log emails, but if I try to configure the SMTPAppender, I get the following error:</p>
  
  <blockquote>
    <p>Logging system failed to initialize using configuration from
    'logback-spring.xml' java.lang.IllegalStateException: Logback
    configuration error detected:  ERROR in
    ch.qos.logback.core.joran.action.AppenderAction - Could not create an
    Appender of type [ch.qos.logback.classic.net.SMTPAppender].
    ch.qos.logback.core.util.DynamicClassLoadingException: Failed to
    instantiate type ch.qos.logback.classic.net.SMTPAppender ERROR in
    ch.qos.logback.core.joran.spi.Interpreter@8:76 - ActionException in
    Action for tag [appender]
    ch.qos.logback.core.joran.spi.ActionException:
    ch.qos.logback.core.util.DynamicClassLoadingException: Failed to
    instantiate type ch.qos.logback.classic.net.SMTPAppender ERROR in
    ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an
    appender named [EMAIL]. Did you define it below instead of above in
    the configuration file? ERROR in
    ch.qos.logback.core.joran.action.AppenderRefAction - See
    <a href="http://logback.qos.ch/codes.html#appender_order" rel="nofollow noreferrer">http://logback.qos.ch/codes.html#appender_order</a> for more details.     at
    org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:162)
      at
    org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSpecificConfig(AbstractLoggingSystem.java:66)
      at
    org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:56)
      at
    org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:115)
      at
    org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:308)
      at
    org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:276)
      at
    org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
      at
    org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:212)
      at
    org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
      at
    org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
      at
    org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
      at
    org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:73)
      at
    org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
      at
    org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:336)
      at
    org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
      at
    org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
      at
    org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
      at
    org.lh.cfpappserver.CfpAppServerApplication.main(CfpAppServerApplication.java:10)
    Exception in thread "main" java.lang.IllegalStateException:
    java.lang.IllegalStateException: Logback configuration error detected:
    ERROR in ch.qos.logback.core.joran.action.AppenderAction - Could not
    create an Appender of type [ch.qos.logback.classic.net.SMTPAppender].
    ch.qos.logback.core.util.DynamicClassLoadingException: Failed to
    instantiate type ch.qos.logback.classic.net.SMTPAppender ERROR in
    ch.qos.logback.core.joran.spi.Interpreter@8:76 - ActionException in
    Action for tag [appender]
    ch.qos.logback.core.joran.spi.ActionException:
    ch.qos.logback.core.util.DynamicClassLoadingException: Failed to
    instantiate type ch.qos.logback.classic.net.SMTPAppender ERROR in
    ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an
    appender named [EMAIL]. Did you define it below instead of above in
    the configuration file? ERROR in
    ch.qos.logback.core.joran.action.AppenderRefAction - See
    <a href="http://logback.qos.ch/codes.html#appender_order" rel="nofollow noreferrer">http://logback.qos.ch/codes.html#appender_order</a> for more details.     at
    org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:315)
      at
    org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:276)
      at
    org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
      at
    org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:212)
      at
    org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
      at
    org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
      at
    org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
      at
    org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:73)
      at
    org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
      at
    org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:336)
      at
    org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
      at
    org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
      at
    org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
      at
    org.lh.cfpappserver.CfpAppServerApplication.main(CfpAppServerApplication.java:10)
    Caused by: java.lang.IllegalStateException: Logback configuration
    error detected:  ERROR in
    ch.qos.logback.core.joran.action.AppenderAction - Could not create an
    Appender of type [ch.qos.logback.classic.net.SMTPAppender].
    ch.qos.logback.core.util.DynamicClassLoadingException: Failed to
    instantiate type ch.qos.logback.classic.net.SMTPAppender ERROR in
    ch.qos.logback.core.joran.spi.Interpreter@8:76 - ActionException in
    Action for tag [appender]
    ch.qos.logback.core.joran.spi.ActionException:
    ch.qos.logback.core.util.DynamicClassLoadingException: Failed to
    instantiate type ch.qos.logback.classic.net.SMTPAppender ERROR in
    ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an
    appender named [EMAIL]. Did you define it below instead of above in
    the configuration file? ERROR in
    ch.qos.logback.core.joran.action.AppenderRefAction - See
    <a href="http://logback.qos.ch/codes.html#appender_order" rel="nofollow noreferrer">http://logback.qos.ch/codes.html#appender_order</a> for more details.     at
    org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:162)
      at
    org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSpecificConfig(AbstractLoggingSystem.java:66)
      at
    org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:56)
      at
    org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:115)
      at
    org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:308)
      ... 13 more</p>
  </blockquote>
  
  <p>This is my configuration in logback-spring.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
      &lt;include resource="org/springframework/boot/logging/logback/defaults.xml"/&gt;
      &lt;property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/&gt;
      &lt;include resource="org/springframework/boot/logging/logback/file-appender.xml"/&gt;
  
  
      &lt;appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"&gt;
          &lt;asynchronousSending&gt;false&lt;/asynchronousSending&gt;
          &lt;smtpHost&gt;smtp.gmail.com&lt;/smtpHost&gt;
          &lt;to&gt;my email&lt;/to&gt;
          &lt;from&gt;my email&lt;/from&gt;
          &lt;username&gt;xxx&lt;/username&gt;
          &lt;password&gt;xxx&lt;/password&gt;
          &lt;subject&gt;%logger{20} - %m&lt;/subject&gt;
          &lt;layout class="ch.qos.logback.classic.html.HTMLLayout"/&gt;
          &lt;cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTracker"&gt;
              &lt;bufferSize&gt;1&lt;/bufferSize&gt;
          &lt;/cyclicBufferTracker&gt;
          &lt;starttls&gt;true&lt;/starttls&gt;
      &lt;/appender&gt;
  
      &lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"&gt;
          &lt;filter class="org.lh.cfpappserver.util.StdOutFilter"/&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;root level="INFO"&gt;
          &lt;appender-ref ref="FILE"/&gt;
          &lt;appender-ref ref="EMAIL"/&gt;
          &lt;appender-ref ref="STDOUT"/&gt;
      &lt;/root&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>What's wrong in my configuration preventing the application to start?</p>