colored log(back) for unit tests in two steps
The goal
![]() |
Make my own stuff yellow, and keep the other stuff grey. |
1. src/test/resources/logback.groovy
(modify the namespace you wanna highlight as your own)
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.boolex.GEventEvaluator | |
import ch.qos.logback.classic.encoder.PatternLayoutEncoder | |
import ch.qos.logback.core.ConsoleAppender | |
import ch.qos.logback.core.filter.EvaluatorFilter | |
import static ch.qos.logback.classic.Level.DEBUG | |
import static ch.qos.logback.core.spi.FilterReply.DENY | |
import static ch.qos.logback.core.spi.FilterReply.NEUTRAL | |
appender("CONSOLE", ConsoleAppender) { | |
encoder(PatternLayoutEncoder) { | |
pattern = "[%thread] %-5level %logger{15} - %msg %n" } | |
filter(EvaluatorFilter) { | |
evaluator(GEventEvaluator) { | |
expression = "!(e.getLoggerName().contains('com.finnjohnsen'))" } | |
onMismatch = DENY onMatch = NEUTRAL } | |
} | |
appender("COLOR_CONSOLE", ConsoleAppender) { | |
withJansi = true encoder(PatternLayoutEncoder) { | |
pattern = "[%thread] %highlight(%-5level) %boldWhite(%logger{15}) - %boldYellow(%msg) %n" } | |
} | |
root(DEBUG, ["CONSOLE"]) | |
logger("com.finnjohnsen", DEBUG, ["COLOR_CONSOLE"]) |
2. Add this to your build.gradle (in addition to logback):
testCompile "org.fusesource.jansi:jansi:1.12"
Done.
Such sites are important because they provide a large dose of useful information ... bitcoin converter widget
ReplyDelete