Search code examples
spring-bootlogback

How to configure logback in spring-boot for ANSI color feature?


I have a spring-boot application running on windows. I have added jansi(v1.8) dependency in my project for enabling colour terminal output on windows.

Have included the logback configuration provided in spring-boot i.e. have added the following line in logback.xml.

<include resource="org/springframework/boot/logging/logback/base.xml" />

I am not clear as what to configure in logback.xml so that it log statements are coloured as per base.xml provided by spring-boot. Sorry, if is a really dumb question, I am a newbie on logback.

Thanks !


Solution

  • Spring boot added support for this:

    https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html#boot-features-logging-color-coded-output

    Just set

    spring.output.ansi.enabled=always