To disable the spring boot banner logo from the 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 the program using setBannerMode(Banner.Mode.OFF)
method call which starts 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 a 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 the comments related to disabling the spring boot logo banner.
Happy Learning !!
References: Spring boot docs
Comments