'Colored logs in IntelliJ with logback custom pattern in yaml configuration of Spring Boot application
Running a SpringBoot application with the default logback pattern configuration shows colored logs:
But when introducing a custom pattern in main.yaml configuration like:
logging:
pattern:
console: "%date %thread %level [%logger{10}:%line] %method | %msg%n"
Colors in logs are gone:
How to maintain colored when changing logback pattern?
Solution 1:[1]
Checking logback documentation on layouts | colouring section explains how to use colors grouping by parentheses.
So tried this pattern configuration:
logging:
pattern:
console: "%date %thread %green(%level) [%cyan(%logger{10}):%magenta(%line)] %red(%method) | %msg%n"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | nephewtom |



