Logback configuration is much easier in groovy than in xml:
import ch.qos.logback.classic.encoder.PatternLayoutEncoder import ch.qos.logback.core.FileAppender import ch.qos.logback.core.ConsoleAppender import static ch.qos.logback.classic.Level.DEBUG import ch.qos.logback.core.status.OnConsoleStatusListener /* * see http://mrhaki.blogspot.in/2010/09/grassroots-groovy-configure-logback.html * and http://logback.qos.ch/manual/groovy.html * for logback.groovy examples */ appender("FILE", FileAppender) { def ts = timestamp("yyyy-MM-dd'_'HH-mm-ss") file = "./logs/trybeTest.${ts}.log" append = true encoder(PatternLayoutEncoder) { pattern = "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n" } } appender("CONSOLE", ConsoleAppender) { //append=true encoder(PatternLayoutEncoder) { pattern = "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n" } } //logger "scratchpad", DEBUG, ["CONSOLE"] root DEBUG, ["FILE", "CONSOLE"]
No comments:
Post a Comment