在開發和測試環境下,ROOT記錄器級別爲DEBUG或INFO。彈簧啓動橫幅顯示在應用程序啓動:顯示帶Root Logger的Spring-Boot Banner WARN
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
但在生產環境中運行時,我的根記錄水平通常是WARN。這導致橫幅不被打印出來。
如何配置logback,以便在生產中顯示橫幅?
我的猜測是,添加另一個記錄儀,但以下(和相似配置)沒有工作:
<logger name="org.springframework.web" level="INFO" additivity="false">
<appender-ref ref="FILE"/>
</logger>
這裏我的配置
application.properties:
spring.main.banner-mode=log
應用-devel.properties:
logging.config=classpath:logging-spring-devel.xml
application-production.properties:
測井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>
測井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>
更改日誌記錄級別爲一類是去照你說的最好的方式。 Spring Boot的另一種方法是通過Environment屬性,我將其作爲JVM參數傳入, -Dlogging.level.org.springframework.boot.SpringApplication = INFO – PaulNUK
工作:)非常感謝。 – Hannes