はじめに
脱XML
最低限やってみた
import static ch.qos.logback.classic.Level.*
import java.nio.charset.Charset
import ch.qos.logback.core.ConsoleAppender
import ch.qos.logback.core.rolling.RollingFileAppender
import ch.qos.logback.core.rolling.TimeBasedRollingPolicy
import ch.qos.logback.core.status.OnConsoleStatusListener
import ch.qos.logback.classic.encoder.PatternLayoutEncoder
statusListener(OnConsoleStatusListener)
scan("10 minutes")
def defaultCharset = Charset.forName("UTF-8")
def defaultPattern = "%date [%highlight(%-5level)] [%thread] [%cyan(%logger{32})] - %message%n"
def defaultHistory = 365
def defaultFilename = "/var/log/hoge/hoge.log"
appender("CONSOLE", ConsoleAppender) {
encoder(PatternLayoutEncoder) {
charset = defaultCharset
pattern = defaultPattern
}
}
appender("FILE", RollingFileAppender) {
fileName = defaultFilename
encoder(PatternLayoutEncoder) {
charset = defaultCharset
pattern = defaultPattern
}
rollingPolicy(TimeBasedRollingPolicy) {
maxHistory = defaultHistory
fileNamePattern = "${defaultFilename}.%d{yyyy-MM-dd}.gz"
}
}
root INFO, ["CONSOLE", "FILE"]