[英]spring boot command line run not using logback-spring.xml
This app works fine in IntelliJ and creates the log files as per configurations, however when launched the app from command line its not using logback-spring.xml file and instead goes on to create *tmp/spring.log file which seems to coming from spring *logback/base.xml.这个应用程序在 IntelliJ 中运行良好,并根据配置创建日志文件,但是当从命令行启动应用程序时,它不使用 logback-spring.xml 文件,而是继续创建似乎来自的 *tmp/spring.log 文件spring *logback/base.xml。 I have spent couple of days to troubleshoot this issue but nothing seems to work so far and other questions do not address the underlying issue, your help is appreciated.我花了几天时间来解决这个问题,但到目前为止似乎没有任何效果,其他问题也没有解决根本问题,感谢您的帮助。
I am launching the app as -我正在启动该应用程序 -
java -jar abc.jar -Dspring.profiles.active=test
I can see that logback-spring.xml is present inside abc.jar as我可以看到 logback-spring.xml 存在于 abc.jar 中
BOOT-INF/classes/ logback-spring.xml BOOT-INF/classes/logback-spring.xml
Here you can find how to configure logback
with spring-boot
howto.logging.logback在这里您可以找到如何使用spring-boot
howto.logging.logback配置logback
With src/main/resources/logback-spring.xml
使用src/main/resources/logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<!-- include spring boot file-appender -->
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" /> <!-- add file-appender -->
</root>
<logger name="com.example" level="DEBUG"/>
</configuration>
And providing a logging file-name in src/main/resources/application.properties
并在src/main/resources/application.properties
中提供日志文件名
logging.file.name=application.log
You should see a file application.log in the same directory as you launched your app with java -jar...
您应该在使用java -jar...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.