当前位置: 首页 > 知识库问答 >
问题:

显示带有根记录器警告的Spring-Boot横幅

夏朝
2023-03-14

在开发和测试环境下,根记录器级别为DEBUG或info。spring-boot横幅在应用程序启动时显示:

2017-03-23 14:31:00,322 [INFO ]                 - 
 :: Spring Boot ::         (v1.5.2.RELEASE)
 :: Application ::         AcMe (v1.0-SNAPSHOT)
 :: Build ::               2017-03-23 09:53
<logger name="org.springframework.web" level="INFO" additivity="false">
    <appender-ref ref="FILE"/>
</logger>
  spring.main.banner-mode=log
  logging.config=classpath:logging-spring-devel.xml
  logging.config=classpath:logging-spring-production.xml

logging-devel.xml(显示横幅)

        LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}application.log}"/>
        <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>${LOG_FILE}</file>
            ...
        </appender>
        <root level="INFO">
            <appender-ref ref="FILE"/>
        </root>
    </configuration>

logging-production.xml(未显示横幅)

        LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}application.log}"/>
        <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>${LOG_FILE}</file>
            ...
        </appender>
        <root level="WARN">
            <appender-ref ref="FILE"/>
        </root>
    </configuration>

共有1个答案

梁丘伟
2023-03-14

在打印横幅期间,Spring Boot使用org.springframework.Boot.springapplication类的记录器,其级别为info

simples解决方案将为这个特定的类启用info级别:

<logger name="org.springframework.boot.SpringApplication"
        level="INFO" additivity="false">
    <appender-ref ref="FILE"/>
</logger>
 类似资料: