To disable the spring boot banner logo from console or log files, we can make changes in 3 possible ways i.e. programmatically, properties or startup arguments.
Banner mode can be set in 3 possible ways:
OFF
– Disable printing of the banner in console and log files.CONSOLE
– Print the banner only to console.LOG
– Print the banner only to the log file.
1. Disable banner programmatically
Set banner mode in program using setBannerMode(Banner.Mode.OFF)
method call which starting the application.
import org.springframework.boot.Banner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication app = new SpringApplication(Application.class); app.setBannerMode(Banner.Mode.OFF); app.run(args); } }
2. Disable banner using properties
Use property key spring.main.banner-mode
to set the banner mode using properties configuration.
spring.main.banner-mode=off
spring: main: banner-mode:"off"
3. Disable banner using startup arguments
Pass the property key spring.main.banner-mode
as startup argument and set the mode there.
workspace> java -Dspring.main.banner-mode=off -jar spring-boot-simple-1.0.jar
Drop me your questions in comments related to disabling spring boot logo banner using spring.main.banner-mode.
Happy Learning !!
References: Spring boot docs