简体   繁体   English

spring 引导命令行运行不使用 logback-spring.xml

[英]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.

相关问题 Spring Boot 忽略 logback-spring.xml - Spring Boot ignoring logback-spring.xml spring boot logback-spring.xml maxFileSize 不适用于 SizeAndTimeBasedRollingPolicy - spring boot logback-spring.xml maxFileSize not working with SizeAndTimeBasedRollingPolicy Spring boot 不加载 logback-spring.xml - Spring boot does not load logback-spring.xml Spring Boot:“无法设置级别:INFO,&#39;org.springframework&#39;的错误”使用logback-spring.xml - Spring Boot : "Cannot set level: INFO, ERROR for 'org.springframework'" using logback-spring.xml 根据logback-spring.xml中的springProfiles [dev,stg,prod],如何激活在命令行中传递的相应spring概要文件 - Depending on springProfiles[dev, stg, prod] in logback-spring.xml , how to activate corresponding spring profile passed in command line SpringBoot logback-spring.xml springprofile不起作用 - SpringBoot logback-spring.xml springprofile is not working 以编程方式外部化logback-spring.xml - Externalize logback-spring.xml programmatically 用新的重新加载logback-spring.xml <maxFileSize></maxFileSize> 无需重启Spring Boot应用 - Reloading logback-spring.xml with new <maxFileSize></maxFileSize> without restarting the spring boot app 当包含定制logback-spring.xml时,Spring Boot应用程序部署失败并显示JNDI警告 - Spring boot application deployment fails with JNDI warnings when custom logback-spring.xml included 无法将config文件夹中logback-spring.xml的属性覆盖到其他模块的logback-spring.xml - Cannot override properties of logback-spring.xml in config folder to other module's logback-spring.xml
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM