I have the following logback.groovy configuration file, and I cannot understand why it is not doing what I would like to do. Ideally, each message in TRACE or higher should be logged in a file, and anything in WARN or higher will be immediately shown on stdout. Unfortunately, I cannot understand that this is happening at all. Any ideas?
import ch.qos.logback.classic.encoder.PatternLayoutEncoder
import ch.qos.logback.core.ConsoleAppender
import ch.qos.logback.core.FileAppender
import static ch.qos.logback.classic.Level.TRACE
import static ch.qos.logback.classic.Level.WARN
def bySecond = timestamp("yyyyMMdd'.'HHmmss", context.birthTime)
appender("STDOUT", ConsoleAppender) {
encoder(PatternLayoutEncoder) {
pattern = "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
}
}
appender("FILE", FileAppender) {
file = "./logs/log-${bySecond}.log"
encoder(PatternLayoutEncoder) {
pattern = "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
}
}
logger("com.foo", WARN, ["STDOUT"])
root(TRACE, ["FILE"])
Thank!
source
share