<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi, <br>
<br>
I am trying to use logback.groovy instead of logback.xml in my
groovy project but I might be missing something:<br>
<br>
$ cat HelloWorld.groovy <br>
@Grab('org.slf4j:slf4j-api:1.6.1')<br>
@Grab('ch.qos.logback:logback-core:1.0.0')<br>
@Grab('ch.qos.logback:logback-classic:1.0.0')<br>
@Grab('ch.qos.logback:logback-examples:1.0.0')<br>
import org.slf4j.Logger<br>
import org.slf4j.LoggerFactory<br>
<br>
public class HelloWorld1 {<br>
<br>
public static void main(String[] args) {<br>
<br>
Logger logger = LoggerFactory.getLogger( "HelloWorld1" )<br>
logger.warn("Hello world.")<br>
}<br>
}<br>
<br>
If I put the first example from
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<a href="http://logback.qos.ch/manual/configuration.html">http://logback.qos.ch/manual/configuration.html</a>
of sample0.xml as logback.xml, it seems to work perfect.<br>
<br>
If I put the logback.groovy equivalent instead, I get various
errors, like :<br>
<br>
$ groovy HelloWorld.groovy <br>
Failed to instantiate [ch.qos.logback.classic.LoggerContext]<br>
Reported exception:<br>
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot
cast object 'ch.qos.logback.core.ConsoleAppender[null]' with class
'ch.qos.logback.core.ConsoleAppender' to class
'ch.qos.logback.core.Appender'<br>
at
org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:331)<br>
<br>
If I only go with the simplest:<br>
<br>
root(DEBUG)<br>
<br>
then I get<br>
<br>
groovy.lang.MissingMethodException: No signature of method:
Script1.root() is applicable for argument types:
(ch.qos.logback.classic.Level) values: [DEBUG]<br>
Possible solutions: wait(), run(), run(), wait(long),
print(java.lang.Object), print(java.lang.Object)<br>
<br>
Below is logback.groovy, could you enlighten me what I am doing
wrong?<br>
<br>
Thanks, <br>
<br>
Tamas<br>
<br>
<br>
============================<br>
@Grab('ch.qos.logback:logback-core:1.0.0')<br>
@Grab('ch.qos.logback:logback-classic:1.0.0')<br>
@Grab('ch.qos.logback:logback-examples:1.0.0')<br>
import ch.qos.logback.classic.encoder.PatternLayoutEncoder<br>
import ch.qos.logback.core.ConsoleAppender<br>
<br>
import static ch.qos.logback.classic.Level.DEBUG<br>
<br>
//appender("STDOUT", ConsoleAppender) {<br>
// encoder(PatternLayoutEncoder) {<br>
// pattern = "%d{HH:mm:ss.SSS} XXX [%thread] %-5level %logger{36}
- %msg%n"<br>
// }<br>
//}<br>
root(DEBUG)<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<a href="http://logback.qos.ch/manual/configuration.html"></a>
</body>
</html>