title: How can I configure Logback SMTP appender on groovy?
body: <p>I am trying to configure Logback SMTP appender using Groovy for my standalone Java application. My logback.groovy file content is below:</p>
  
  <pre><code>    import ch.qos.logback.classic.PatternLayout
      import ch.qos.logback.classic.encoder.PatternLayoutEncoder
      import ch.qos.logback.classic.net.SMTPAppender
      import ch.qos.logback.core.ConsoleAppender
  
      import static ch.qos.logback.classic.Level.INFO
  
      def common_log_date_format = "{MM/dd HH:mm:ss:SSS}"
      def common_log_conversionpattern = "[%d${common_log_date_format}] [%t] [%c{0}] [%p]: %m%n"
  
      appender("STDOUT", ConsoleAppender) {
        encoder(PatternLayoutEncoder) {
          pattern = "${common_log_conversionpattern}"
        }
      }
  
      appender("EMAIL", SMTPAppender) {
        smtpHost = "xxxx"
        to = "yyyy"
        from = "zzzz"
        subject = "[${app.name}] [%marker] [%p]"
        asynchronousSending = false
        layout(PatternLayout) {
          pattern = "${common_log_conversionpattern}"
        }
      }
  
      root(INFO, ["STDOUT", "EMAIL"])
  </code></pre>
  
  <p>But this config does not work, it fails during app startup with:</p>
  
  <pre><code>Failed to instantiate [ch.qos.logback.classic.LoggerContext]
  Reported exception:
  java.lang.NullPointerException: Cannot get property 'name' on null object
  at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:56)
  at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:168)
  at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:44)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
  at Script1$_run_closure2.doCall(Script1.groovy:22)
  at Script1$_run_closure2.doCall(Script1.groovy)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
  at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
  at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
  at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
  at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
  at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
  at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
  at ch.qos.logback.classic.gaffer.ConfigurationDelegate.appender(ConfigurationDelegate.groovy:141)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
  at org.codehaus.groovy.runtime.metaclass.MixinInstanceMetaMethod.invoke(MixinInstanceMetaMethod.java:53)
  at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoMetaMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:313)
  at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:52)
  at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
  at Script1.run(Script1.groovy:18)
  at Script1$run.call(Unknown Source)
  at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
  at ch.qos.logback.classic.gaffer.GafferConfigurator.run(GafferConfigurator.groovy:64)
  at ch.qos.logback.classic.gaffer.GafferConfigurator$run.callCurrent(Unknown Source)
  at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
  at ch.qos.logback.classic.gaffer.GafferConfigurator.run(GafferConfigurator.groovy:40)
  at ch.qos.logback.classic.gaffer.GafferUtil.runGafferConfiguratorOn(GafferUtil.java:43)
  at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:65)
  at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148)
  at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
  at org.slf4j.impl.StaticLoggerBinder.&lt;clinit&gt;(StaticLoggerBinder.java:55)
  at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
  at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)
  at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)
  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
  at com.revere.edm.job.Loader.&lt;init&gt;(Loader.java:13)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
  at java.lang.Class.newInstance(Class.java:374)
  at com.revere.shell.Shell.execute(Shell.java:233)
  at com.revere.shell.Shell.main(Shell.java:64)
  </code></pre>
  
  <p>I cannot understand the reason of this message. If I remove SMTP Appender configuration part from config - application works and logs fine.
  How can I make SMTP appende work with groovy configuration?</p>
  
  <p>My environment is: Ubuntu 12.04, logback classic/core 1.0.13, Groovy-all jar version 2.2.0-rc-3, Janino 2.6.1, javax.mail 1.4.</p>