Created
September 23, 2014 09:51
-
-
Save ChinaXing/0978b1d43af9e5ff2882 to your computer and use it in GitHub Desktop.
logback groovy 配置 - 防止掉坑
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ch.qos.logback.classic.encoder.PatternLayoutEncoder | |
import ch.qos.logback.classic.filter.LevelFilter | |
import ch.qos.logback.core.rolling.RollingFileAppender | |
import ch.qos.logback.core.rolling.TimeBasedRollingPolicy | |
import ch.qos.logback.core.spi.FilterReply | |
def LOG_BASE = System.getProperty("DB2MQ_HOME") + "/logs" | |
def PATTERN = "%date %level [%thread] %logger{10} [%X] [%file:%line] %msg%n" | |
appender("Console", ConsoleAppender) { | |
encoder(PatternLayoutEncoder) { | |
pattern = "${PATTERN}" | |
} | |
} | |
appender("Default", RollingFileAppender) { | |
file = "${LOG_BASE}/default.log" | |
append = true | |
rollingPolicy(TimeBasedRollingPolicy) { | |
fileNamePattern = "${LOG_BASE}/default-%d{yyyy-MM-dd}.log" | |
maxHistory = 5 | |
} | |
encoder(PatternLayoutEncoder) { | |
pattern = "${PATTERN}" | |
} | |
} | |
appender("AppDebug", RollingFileAppender) { | |
file = "${LOG_BASE}/app.debug.log" | |
append = true | |
rollingPolicy(TimeBasedRollingPolicy) { | |
fileNamePattern = "${LOG_BASE}/app-%d{yyyy-MM-dd}.debug.log" | |
maxHistory = 2 | |
} | |
encoder(PatternLayoutEncoder) { | |
pattern = "${PATTERN}" | |
} | |
} | |
appender("AppWarn", RollingFileAppender) { | |
file = "${LOG_BASE}/app.warn.log" | |
append = true | |
filter(LevelFilter) { | |
level = WARN | |
onMatch = FilterReply.ACCEPT | |
onMismatch = FilterReply.DENY | |
} | |
rollingPolicy(TimeBasedRollingPolicy) { | |
fileNamePattern = "${LOG_BASE}/app-%d{yyyy-MM-dd}.warn.log" | |
maxHistory = 5 | |
} | |
encoder(PatternLayoutEncoder) { | |
pattern = "${PATTERN}" | |
} | |
} | |
appender("AppError", RollingFileAppender) { | |
file = "${LOG_BASE}/app.err.log" | |
append = true | |
filter(LevelFilter) { | |
level = ERROR | |
onMatch = FilterReply.ACCEPT | |
onMismatch = FilterReply.DENY | |
} | |
rollingPolicy(TimeBasedRollingPolicy) { | |
fileNamePattern = "${LOG_BASE}/app-%d{yyyy-MM-dd}.err.log" | |
maxHistory = 5 | |
} | |
encoder(PatternLayoutEncoder) { | |
pattern = "${PATTERN}" | |
} | |
} | |
appender("AppInfo", RollingFileAppender) { | |
file = "${LOG_BASE}/app.info.log" | |
append = true | |
filter(LevelFilter) { | |
level = INFO | |
onMatch = FilterReply.ACCEPT | |
onMismatch = FilterReply.DENY | |
} | |
rollingPolicy(TimeBasedRollingPolicy) { | |
fileNamePattern = "${LOG_BASE}/app-%d{yyyy-MM-dd}.info.log" | |
maxHistory = 5 | |
} | |
encoder(PatternLayoutEncoder) { | |
pattern = "${PATTERN}" | |
} | |
} | |
logger("com.mogujie.dbtomq", DEBUG, ["AppError", "AppWarn", "AppInfo", "AppDebug"], false) | |
root(INFO, ["Default"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment