[logback-user] Groovy-config fails without outside code noticing.

Ceki Gulcu ceki at qos.ch
Fri Nov 18 15:36:55 CET 2011


Hi Endre,

This is obviously a bug. Could you please enter a bug report on this 
issue? Your description of the problem below is perfectly sufficient.

Thanks,
--
Ceki

On 18.11.2011 13:39, Endre Stølsvik wrote:
> Hi!
>
> This groovy-file ...:
>
> import ch.qos.logback.classic.PatternLayout
> import ch.qos.logback.core.ConsoleAppender
> import ch.qos.logback.core.encoder.LayoutWrappingEncoder
>
> appender("STDOUT", ConsoleAppender) {
>   encoder(LayoutWrappingEncoder) {
>     layout(PatternLayout) {
>       pattern = "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{55}.%M.%L -
> %msg%n"
>     }
>   }
> }
>
> root(ALL, ["STDOUT"])
>
> ... apparently crashes the configuration as such:
>
> Failed to instantiate [ch.qos.logback.classic.LoggerContext]
> Reported exception:
> groovy.lang.MissingPropertyException: No such property: ALL for class:
> Script1
>      at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
>      at
> org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
>      at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
>      at Script1.run(Script1.groovy:13)
>      at Script1$run.call(Unknown Source)
>      at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
>      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:59)
>      at
> ch.qos.logback.classic.gaffer.GafferConfigurator$run.callCurrent(Unknown
> Source)
>      at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
>      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:37)
>      at
> ch.qos.logback.classic.gaffer.GafferUtil.runGafferConfiguratorOn(GafferUtil.java:44)
>      at
> ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:67)
>      at
> ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
>      at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
>      at
> org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
>      at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
>      at
> org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
>      at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:279)
>      at XYZ.doLogConfig(XYZ.java:40)
>      at XYZ.main(XYZ:169)
>
>
> /
> The problem is obviously the not-defined property "ALL". The problem I
> am reporting is that this isn't caught./
>
>
> The console-dump happens in the /"We should never get here"/ catch block
> below:
>
>    void init() {
>      try {
>        try {
>          new ContextInitializer(defaultLoggerContext).autoConfig();
>        } catch (JoranException je) {
>          Util.report("Failed to auto configure default logger context", je);
>        }
>        StatusPrinter.printInCaseOfErrorsOrWarnings(defaultLoggerContext);
>        contextSelectorBinder.init(defaultLoggerContext, KEY);
>        initialized = true;
>      } catch (Throwable t) {
>        // we should never get here
>        Util.report("Failed to instantiate [" + LoggerContext.class.getName()
>            + "]", t);
>      }
>    }
>
>
> Notice that the StatusManager does not know that the config failed:
>
> 13:32:07,643 |-INFO in ch.qos.logback.classic.LoggerContext[Emma
> logcontext] - Found resource [logback.groovy] at
> [file:/XYZ/target/classes/logback.groovy]
> 13:32:08,807 |-INFO in
> ch.qos.logback.classic.gaffer.ConfigurationDelegate at 2111e072 - About to
> instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
> 13:32:08,809 |-INFO in
> ch.qos.logback.classic.gaffer.ConfigurationDelegate at 2111e072 - Naming
> appender as [STDOUT]
>
> Kind regards,
> Endre Stølsvik.
>


More information about the Logback-user mailing list