Last active
August 29, 2015 14:02
-
-
Save mrorii/bd5f0447898b805fb326 to your computer and use it in GitHub Desktop.
logback + logstash
This file contains 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
dependencies { | |
compile group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '2.8' | |
} |
This file contains 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.core.ConsoleAppender | |
import ch.qos.logback.core.rolling.RollingFileAppender | |
import ch.qos.logback.core.rolling.TimeBasedRollingPolicy | |
import ch.qos.logback.core.status.OnConsoleStatusListener | |
import net.logstash.logback.encoder.LogstashEncoder | |
import static ch.qos.logback.classic.Level.INFO | |
import static ch.qos.logback.classic.Level.DEBUG | |
import static ch.qos.logback.classic.Level.WARN | |
import static ch.qos.logback.classic.Level.TRACE | |
import static ch.qos.logback.classic.Level.ERROR | |
import static ch.qos.logback.classic.Level.OFF | |
// "log" any logging related issues | |
statusListener(OnConsoleStatusListener) | |
appender("FILE", RollingFileAppender) { | |
rollingPolicy(TimeBasedRollingPolicy) { | |
fileNamePattern = "/tmp/foobar.%d{yyyy-MM-dd-HH}.log" | |
maxHistory = 336 | |
} | |
encoder(LogstashEncoder) { | |
enableContextMap = true | |
} | |
} | |
root(DEBUG, ["FILE"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment