- Published on
Adding Colour to Logback Logs
- Authors
- Name
- Yair Mark
- @yairmark
Today I was going through the Kotlin Micronaut example when I came across their logback config file:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<withJansi>true</withJansi>
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n
</pattern>
</encoder>
</appender>
<root level="info">
<appender-ref ref="STDOUT"/>
</root>
<!--<logger name="io.micronaut.context" level="TRACE"/>-->
</configuration>
What is interesting is that they use colours when defining their patterns which is something I never knew logback could do. Looking through the logback documentation I found this page and specifically the Coloring
section which coverts this in more detail.