1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| @Grapes([ @Grab(group='ch.qos.logback', module='logback-classic', version='1.2.3') ])
import static ch.qos.logback.classic.Level.TRACE import static ch.qos.logback.classic.Level.DEBUG import static ch.qos.logback.classic.Level.INFO import static ch.qos.logback.classic.Level.WARN import static ch.qos.logback.classic.Level.ERROR
import ch.qos.logback.classic.encoder.PatternLayoutEncoder import ch.qos.logback.core.ConsoleAppender import ch.qos.logback.classic.AsyncAppender
scan("30 seconds") def LOG_PATH="logs" def LOG_ARCHIVE="${LOG_PATH}/archive"
appender("Console-Appender", ConsoleAppender) { encoder(PatternLayoutEncoder) { pattern = "[%d{yyyy-MM-dd HH:mm:ss.SSS Z}] [%logger{16}] [%thread] [%level] %msg%n" } } appender("File-Appender", FileAppender) { file = "${LOG_PATH}/logfile.log" encoder(PatternLayoutEncoder) { pattern = "%d{ISO8601,+0800} %logger{16} [%thread] %msg%n" outputPatternAsHeader = true } } appender("RollingFile-Appender", RollingFileAppender) { file = "${LOG_PATH}/rollingfile.log" rollingPolicy(TimeBasedRollingPolicy) { fileNamePattern = "${LOG_ARCHIVE}/rollingfile.log%d{yyyy-MM-dd}.log" maxHistory = 30 totalSizeCap = "1KB" } encoder(PatternLayoutEncoder) { pattern = "[%d{yyyy-MM-dd HH:mm:ss.SSS Z}] [%logger{16}] [%thread] [%level] %msg%n" } } appender("Async-Appender",AsyncAppender){ appenderRef("RollingFile-Appender") }
logger("StandardGreeting",DEBUG,["File-Appender"]) logger("IceGreeting", DEBUG, ["Console-Appender", "File-Appender", "Async-Appender"], false) root(INFO,["Console-Appender"])@Grapes([ @Grab(group='ch.qos.logback', module='logback-classic', version='1.2.3') ])
import static ch.qos.logback.classic.Level.INFO import static ch.qos.logback.classic.Level.DEBUG
import ch.qos.logback.classic.encoder.PatternLayoutEncoder import ch.qos.logback.core.ConsoleAppender
appender("CONSOLE", ConsoleAppender) { encoder(PatternLayoutEncoder) { pattern = "%-4relative [%thread] - %msg%n" } } root(DEBUG, ["CONSOLE"])
|