我有Spring Boot應用程序,它在內部使用帶有log4j日誌記錄的庫。Spring Boot的baner和log4j apears在控制檯中
我裏面的pom.xml添加(到log4j的條目附加到我的logback日誌):
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</dependency>
根據http://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html#howto-configure-logback-for-logging-fileonly我添加了自定義的logback-spring.xml應禁用控制檯日誌輸出:
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/>
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<root level="INFO">
<appender-ref ref="FILE" />
</root>
</configuration>
的問題是後:
java -jar my-app.jar &
baner.txt及以下warni ng仍寫入控制檯:
. ____ _ __ _ _
/\\/___'_ __ _ _(_)_ __ __ _ \ \ \ \
(()\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ))))
' |____| .__|_| |_|_| |_\__, |////
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.2.RELEASE)
log4j:WARN No appenders could be found for logger (package.hidden).
log4j:WARN Please initialize the log4j system properly.
問題1:如何完全禁用控制檯日誌? Q2:如何將log4j日誌附加到logback文件輸出?
好吧,我排除在我的圖書館log4j的,並警告不顯示。但是baner仍然可見。 –