1. Overview

At starting of spring boot application, Banner is displayed at console but sometimes for production or client delivery, we do not require those type of banner or so this blog is related to Spring boot disable banner from the console or log.

To disable banner is last option if you do not text insider banner, Sring boot also provides ways to customize banner here is document using that can customize banner.

Benner that I am talking about is like bellow which contains spring boot version and “spring” written as text:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.8.RELEASE)

1. Disable Spring boot Banner using Java Code

package com.javadeveloperzone;

import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;


/**
 * Created by JavaDeveloperZone on 19-07-2017.
 */

@SpringBootApplication
@ComponentScan
// Using a root package also allows the @ComponentScan annotation to be used without needing to specify a basePackage attribute
public class SpringBootConfig {
    
    public static void main(String[] args) throws Exception {
        SpringApplication app = new SpringApplication(SpringBootConfig.class);
        app.setBannerMode(Banner.Mode.OFF);     // it will disable banner, Banner.Mode.CONSOLE for display at console(default),
                                                // Banner.Mode.LOG for display at LOG file
        app.run(args);        // it wil start application
    }
}

2. Disable spring boot banner using configuration properties

If we do not like to disable banner but want to print banner in Log file then we can set log so banner will be displayed in a log file. Here is all possible value which is supported by spring.main.banner-mode application.properties.

Other properties spring.main.show-banner  which is now deprecated after spring boot 1.3

off: disable banner
log: Display banner in the log file
console: Display banner on the console

2.1 application.properties

spring.main.banner-mode=off

or

2.2 application.yml

spring:
  main:
    banner-mode: off

3. Conclusion

This is the very short article, But I think that It will be helpful to your to disable banner insider spring boot application. spring.main.banner-mode is an alternative of spring.main.show-banner.

4. References

Was this post helpful?
Let us know, if you liked the post. Only in this way, we can improve us.
Yes
No

Leave a Reply

Your email address will not be published. Required fields are marked *