Getting Spring Boot color console logging working within Intellij?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Spring Boot is a powerful framework for developing Java-based applications. One of its attractive features is its built-in logging capability which outputs structured logs to the console. By default, these logs can be colorized, but getting those colorful logs out of Spring Boot and into your IntelliJ console can sometimes be a bit tricky. In this article, we will explore how to achieve color console logging within IntelliJ when using Spring Boot. This will make debugging and reading your logs a more enjoyable and efficient task.
Configuring Spring Boot for Colorized Console Output
Spring Boot uses the popular logging library Logback as the default logging mechanism. Logback provides ANSI color codes capabilities, which is what enables colored console output. However, there are certain prerequisites and configurations that must be set up to ensure it works correctly within IntelliJ.
Prerequisites
- Java Version: Ensure that you are using JDK 8 or later. Previous versions may not fully support colored console output.
- IntelliJ IDEA Version: The version of IntelliJ should be recent enough to support ANSI coloring natively in its terminals. Versions after IntelliJ IDEA 2018.3 generally have good support.
Steps to Enable Color Logging
- Update
application.properties:Ensure that yoursrc/main/resources/application.propertiesfile contains the following property:
This property enforces Spring Boot to output ANSI color codes in logs regardless of the terminal environment, which is crucial for IntelliJ.
- Check IntelliJ Terminal Settings:IntelliJ IDEA’s terminal and console must be set to support ANSI coloring. Go to
File -> Settings (or Preferences on macOS) -> Editor -> Color Scheme -> Console Colors, and ensure that the optionUse color scheme font in consoleis enabled. - Add ANSI Escape Sequences:If you're using a custom logging format in your
logback-spring.xml, make sure you include patterns with ANSI escape sequences. Here is an example configuration:
The %highlight pattern is particularly important as it is responsible for applying colors based on the log level.
Examining the Output
Once configured, run your Spring Boot application. The logs should now appear in color within the IntelliJ console:
- INFO messages will generally appear in white or green.
- WARN messages may appear in yellow.
- ERROR messages will be displayed in red.
This is controlled by the Logback formatting as well as IntelliJ’s ANSI support.
Troubleshooting Common Issues
Despite the straightforward setup, issues can arise. Here are some common problems and their solutions:
- Logs are not colorized:
- Ensure
spring.output.ansi.enabled=ALWAYSis set. - Double-check version compatibility for both IntelliJ and JDK.
- Error with ANSI codes in Logs:
- Ensure your IntelliJ console is set to handle ANSI escape codes, or update to a more recent version.
Summary
The following table summarizes key configuration points for enabling color logs in Spring Boot when using IntelliJ:
| Attribute | Description | Required Action |
| Java Version | JDK 8 or later. | Update Java if necessary. |
| IntelliJ Version | 2018.3 or later recommended. | Update IntelliJ if necessary. |
spring.output.ansi.enabled property | Enables ANSI codes in logs. | Set property to ALWAYS. |
| IntelliJ Terminal Settings | Configure to support ANSI coloring. | Enable Use color scheme font in console. |
| Logback Configuration | Use %highlight in log patterns. | Adjust logback-spring.xml. |
In summary, leveraging color console logging in Spring Boot enhances the readability of logs, making it quicker and easier to identify issues and understand log output. With the correct configurations in both Spring Boot and IntelliJ IDEA, you can take full advantage of this feature, enabling more efficient debugging and development processes.
Related reading
- git remote add with other SSH port
- GitHub Actions build outside vs inside container?
- Good examples using java.util.logging
- Google cloud Kubernetes deployment error Field is immutable
- Getting the array length of a 2D array in Java
- Getting the class name from a static method in Java
- Graceful shutdown of golang web server
- Hardware requirement for apache kafka

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.