Skip to content

Instantly share code, notes, and snippets.

@aaronzirbes
Created September 23, 2015 04:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronzirbes/d54a74a3da0f26edab77 to your computer and use it in GitHub Desktop.
Save aaronzirbes/d54a74a3da0f26edab77 to your computer and use it in GitHub Desktop.
Logback Groovy Config
import static ch.qos.logback.classic.Level.DEBUG
import static ch.qos.logback.classic.Level.INFO
final String APP = 'my-app'
final String LOG_PATH = "/var/log/${APP}"
include 'org/springframework/boot/logging/logback/base.xml'
appender('STDOUT', ConsoleAppender) {
encoder(PatternLayoutEncoder) {
//pattern = '%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n'
pattern = '%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${PID:- } --- [%t] %msg%n'
}
}
appender("FILE", RollingFileAppender) {
String outputLog = "${LOG_PATH}/${APP}.log"
file = outputLog
append = true
encoder(PatternLayoutEncoder) {
//pattern = '%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n'
pattern = '%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${PID:- } --- [%t] %msg%n'
}
rollingPolicy(FixedWindowRollingPolicy) {
fileNamePattern = "${LOG_PATH}/${APP}.%i.log.gz"
minIndex = 1
maxIndex = 9
}
triggeringPolicy(SizeBasedTriggeringPolicy) {
maxFileSize = '5MB'
}
}
//logger("com.mnclimbingcoop", DEBUG, ['STDOUT'], true)
root(INFO, ['FILE', 'STDOUT'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment