首页  

springboot应用日志无法输出到指定目录     所属分类 springboot 浏览量 672
springboot2 应用


java -jar xxx.jar

application.properties
里配置了日志路径 ,却没有输出

app.output=/tmp/output/${app.name}
logging.path=${app.output}


/actuator/env/app.output
{
    "source": "applicationConfig: [classpath:/application-default.properties]",
    "value": "/tmp/output/xxx"
}

原来jar包里有一个 application-default.properties
配置了 app.output

在外头 定义一个  application-default.properties 
配置生效

{
    "source": "applicationConfig: [file:./application-default.properties]",
    "value": "/PATH/logs/"
}

JAR包里 logback-spring.xml
外面加了一个 logback-spring.xml ,无法覆盖

application.properties 里配置
logging.config=logback-spring-xxx.xml 
配置生效
如果配置
classpath:logback-spring-xxx.xml 
则报错
java.io.FileNotFoundException: class path resource [logback-spring-xxx.xml] cannot be resolved to URL because it does not exist

为何Springboot推荐使用logback-spring.xml来替代logback.xml

logback.xml加载早于application.properties
如果在logback.xml使用变量,
且变量是在application.properties 定义的,那么就会获取不到
改成logback-spring.xml就可以解决


打包时配置不要打进去,全部外置比较好


目录结构 application-default.properties application.properties logback-spring-xxx.xml logs xxx.jar

上一篇     下一篇
C++左值和右值

springboot jar包无法解压

2021年1到8月主要税收收入

C++面试知识点

springboot tomcat 监控指标

各行业编程语言流行榜