[logback-user] Groovy Configuration

Lance White lance.white at logicscope.com
Wed Jun 30 15:43:34 CEST 2010


Afraid not...

I seem to get a variety of errors depending on what the script file is...

With a script file called 'aaa.groovy' in the current working directory (c:\tmp) :

If I call gafferConfigurator.run("aaa.groovy"); or I call gafferConfigurator.run("c:/tmp/aaa.groovy"); then I get 

groovy.lang.MissingPropertyException: No such property: aaa for class: Script1
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:49)
	at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:241)
	at Script1.run(Script1.groovy:1)
	at Script1$run.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:121)
	at ch.qos.logback.classic.gaffer.GafferConfigurator.run(GafferConfigurator.groovy:58)
	at test.test3.run(test3.java:32)
	at test.test3.main(test3.java:59)

whereas if I call gafferConfigurator.run("c:\\tmp\\aaa.groovy"); I get 

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 1: unexpected char: '\' @ line 1, column 3.
   C:\tmp\aaa.groovy
     ^

1 error

	at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:296)
	at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:143)
	at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:113)
	at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:125)
	at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:353)
	at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:99)
	at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:71)
	at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:249)
	at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:160)
	at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:845)
	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:521)
	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:497)
	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:474)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:292)
	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:727)
	at groovy.lang.GroovyShell.parse(GroovyShell.java:739)
	at groovy.lang.GroovyShell.parse(GroovyShell.java:766)
	at groovy.lang.GroovyShell.parse(GroovyShell.java:757)
	at groovy.lang.GroovyShell$parse.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at ch.qos.logback.classic.gaffer.GafferConfigurator.run(GafferConfigurator.groovy:47)
	at test.test3.run(test3.java:34)
	at test.test3.main(test3.java:61)

Cheers

Lance


> -----Original Message-----
> From: logback-user-bounces at qos.ch [mailto:logback-user-bounces at qos.ch]
> On Behalf Of Ceki Gülcü
> Sent: 30 June 2010 14:17
> To: logback users list
> Subject: Re: [logback-user] Groovy Configuration
> 
> Hi Lance,
> 
> 
> If your config file is called logback.groovy, logback will
> automatically pick it up. To programmatically invoke a groovy config
> file, you would need to work with "GafferConfigurator" as Joran only
> deals with XML files, not Groovy. You would write:
> 
> import ch.qos.logback.classic.gaffer.GafferConfigurator;
> import ch.qos.logback.classic.LoggerContext;
> 
> ...
> 
> LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
> GafferConfigurator gafferConfigurator = new GafferConfigurator(lc);
> gafferConfigurator.run(configFile);
> 
> Let us know if the above works,
> 
> On 30/06/2010 3:06 PM, Lance White wrote:
> > Hi,
> >
> > I'm having a play with the Groovy Configuration (in 0.9.23), but
> can't
> > see how you're supposed to tell your program to use the Groovy
> > configuration file. In normal circumstances, I'd use Joran to load a
> > given XML file, but can't see what the equivalent would be for
> Groovy.
> >
> > I tried just executing the Groovy script (using the Java 1.6 script
> > engine system) but just get a groovy.lang.MissingMethodException when
> it
> > tries to execute the appender line (I'm using the first example
> script
> > on the Groovy Configuration page).
> >
> > Am I missing something obvious here?
> >
> > The Groovy version is 1.7.1.
> >
> > Cheers
> >
> > Lance
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user


More information about the Logback-user mailing list