Spring Boot
Disable Logo
Application Configuration
Java Development
Logging

How to disable spring boot logo in stdout?

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Spring Boot, a framework built on top of Spring, is designed to simplify the setup and development of new Java applications. By default, when a Spring Boot application starts, it displays a startup banner in the console with the Spring Boot version, project name, and some basic status information. While this branding is useful for quickly identifying the software running, there might be scenarios where a developer wishes to disable this banner for cleaner logs, especially in production environments. Here's how you can disable the Spring Boot logo in the standard output (stdout).

Understanding the Startup Banner

When a Spring Boot application launches, it displays a startup banner. This banner can be seen in the console and usually includes a Spring Boot ASCII art logo, version, and other information about the application context. This is managed by the Banner interface in Spring Boot.

Methods to Disable the Banner

Disabling the Spring Boot startup banner is quite simple and can be achieved in multiple ways:

1. Using Application Properties

One of the simplest ways to turn off the Spring Boot banner is by setting a property in the application.properties or application.yml file.

  • application.properties: Add the following line:
properties
  spring.main.banner-mode=off
  • application.yml: Use this setting:
yaml
  spring:
    main:
      banner-mode: "off"

2. Programmatically

Another way to disable the banner is programmatically by modifying the SpringApplicationBuilder or SpringApplication class.

java
1import org.springframework.boot.SpringApplication;
2import org.springframework.boot.autoconfigure.SpringBootApplication;
3
4@SpringBootApplication
5public class MyApplication {
6    public static void main(String[] args) {
7        SpringApplication app = new SpringApplication(MyApplication.class);
8        app.setBannerMode(Banner.Mode.OFF);
9        app.run(args);
10    }
11}

3. Command-Line Arguments

Spring Boot also allows overriding configuration properties directly from the command line. You can disable the banner by providing a command-line argument when running your jar file:

bash
java -jar myapp.jar --spring.main.banner-mode=off

4. Environment Variable

Set an environment variable if you want a system-wide preference:

bash
export SPRING_MAIN_BANNER_MODE=off

Summary Table

Here’s a quick summary of the various methods to disable the Spring Boot Logo:

MethodConfiguration/Command
Application Propertiesspring.main.banner-mode=off
Application YAMLspring: main: banner-mode: "off"
Programmaticallyapp.setBannerMode(Banner.Mode.OFF)
Command-Line Argumentjava -jar myapp.jar --spring.main.banner-mode=off
Environment Variableexport SPRING_MAIN_BANNER_MODE=off

Additional Details

Customizing instead of Disabling

Instead of disabling, you may wish to customize the banner to display relevant information more pertinent to your application environment. Customize the banner by creating a banner.txt file in the src/main/resources directory. Contents of this file will replace the default banner.

Why Disable the Banner?

  • Cleaner Logs: In a production environment, clarity in logging is critical. Disabling unnecessary output can help in reading log files more easily.
  • Security: While unlikely, exposing software versions may aid attackers. Removing version data and branding can marginally deter amateur attacks.
  • Brand Customization: Organizations might want to replace the default Spring Boot branding with their own.

Caveats

While disabling the banner is straightforward, make sure that it aligns with your project goals. If other team members prefer seeing the startup banner or if it helps in debugging issues during development, consider their needs and preferences.

The customization options provided by Spring Boot reflect its flexibility in catering to various development scenarios. Disabling non-essential features like the startup banner is just one part of optimizing your Spring Boot application for production settings.


Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track 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.

Practice system design

All Rights Reserved.