如何在标准输出中禁用Spring Boot徽标? [英] how to disable spring boot logo in stdout?

查看:111
本文介绍了如何在标准输出中禁用Spring Boot徽标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以禁用可爱但非常明显的ASCII Spring引导徽标:

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

...每次运行spring boot应用程序时都会将其转储到STDOUT中吗?

我在logback.xml中将所有日志记录都切换为ERROR,但是什么也没做:

<root level="ERROR">
    <appender-ref ref="STDOUT" />
</root>

在文档中未将其称为徽标".搜索友好术语是横幅".

解决方案

3)主要方法

public static void main(String[] args) {
    SpringApplication app = new SpringApplication(MySpringConfiguration.class);
    app.setBannerMode(Banner.Mode.OFF);
    app.run(args);
}

文档

要使用和环境变量更改此属性,请使用带下划线而不是点的属性.试试:

SPRING_MAIN_BANNER-MODE =关闭

请参见 docs 进行外部配置.

Is there a way to disable the lovely but very visible ASCII Spring boot logo :

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

...dumped in STDOUT every time your run a spring boot app?

I switched all logging to ERROR in my logback.xml, but that did nothing:

<root level="ERROR">
    <appender-ref ref="STDOUT" />
</root>

edit: It's not called a "Logo" in the documentation. The search-friendly-term is a "banner".

解决方案

http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-banner

new SpringApplicationBuilder()
    .showBanner(false)
    .sources(Parent.class)
    .child(Application.class)
    .run(args);

Edit In the newer versions of spring boot(current is 1.3.3) the way to do it is:

1) application.properties

spring.main.banner-mode=off

2) application.yml

spring:
    main:
        banner-mode: "off"

3) main method

public static void main(String[] args) {
    SpringApplication app = new SpringApplication(MySpringConfiguration.class);
    app.setBannerMode(Banner.Mode.OFF);
    app.run(args);
}

Docs

Edit:

To change this with and environment variable use the property with underscore instead of dot. Try:

SPRING_MAIN_BANNER-MODE=off

See the docs for externalized config.

这篇关于如何在标准输出中禁用Spring Boot徽标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆