Published on

Adding Colour to Logback Logs


Today I was going through the Kotlin Micronaut example when I came across their logback config file:


 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">


 <!-- encoders are assigned the type

 ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->


 <pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n




 <root level="info">

 <appender-ref ref="STDOUT"/>


 <!--<logger name="io.micronaut.context" level="TRACE"/>-->


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.