[logback-dev] [JIRA] Created: (LBCLASSIC-309) Groovy-config fails without outside code noticing
Endre Stølsvik (JIRA)
noreply-jira at qos.ch
Fri Nov 18 17:05:12 CET 2011
Groovy-config fails without outside code noticing
-------------------------------------------------
Key: LBCLASSIC-309
URL: http://jira.qos.ch/browse/LBCLASSIC-309
Project: logback-classic
Issue Type: Bug
Components: joran
Affects Versions: unspecified
Environment: na
Reporter: Endre Stølsvik
Assignee: Logback dev list
Priority: Minor
[As reported on the user-list, where I was requested to make a bug report]
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, as the error message states, 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]
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the logback-dev
mailing list