Spring Boot - Enabling Color Coded Output

[Last Updated: Sep 22, 2017]

Spring boot can display ANSI color coded output if the target terminal supports it. We need to set spring.output.ansi.enabled property. The possible values are ALWAYS, DETECT and NEVER.




Note that the property spring.output.ansi.enabled is set to 'DETECT' value by default, but not all terminals will show the colored output unless we set it to 'ALWAYS'. Also if we set the value 'ALWAYS' and if the target terminal does not support ANSI codes then instead of colored output, the raw embedded color codes will be shown in the logs.

An example bean

package com.logicbig.example;

import org.springframework.stereotype.Component;

import java.util.logging.Logger;

public class MyBean {
  private static final Logger logger = Logger.getLogger(MyBean.class.getName());

  public void doSomething() {"some message");

The Main class

public class ExampleMain {

  public static void main(String[] args) throws InterruptedException {
      ConfigurableApplicationContext context =
    , args);
      MyBean bean = context.getBean(MyBean.class);



IntelliJ shows the colored output without any extra configuration. Running the main class (IntelliJ Community Edition 2016.3):


In Eclipse, you have to install an additional plugin from here. Running the main class (Eclipse 4.6.0 - Neon):

Windows power shell

Running from Windows 10 PowerShell

 mvn -q spring-boot:run

It does not work in Windows cmd.exe.

Bash running in Linux Mint

Running the executable jar of above example in Linux Mint (18.1) accessed via putty.

 java -jar boot-color-console-output.jar

The standalone executable jar above was created with Spring Boot Maven plugin.

Example Project

Dependencies and Technologies Used:

  • Spring Boot 1.5.7.RELEASE
    Corresponding Spring Version 4.3.11.RELEASE
  • spring-boot-starter : Core starter, including auto-configuration support, logging and YAML.
  • JDK 1.8
  • Maven 3.3.9

Color-coded Console Output Example Select All Download
  • boot-color-console-output
    • src
      • main
        • java
          • com
            • logicbig
              • example
        • resources

    See Also