springboot启动时,优先加载logback.xml,所以在application.yml中定义的配置,在logback.xml中获取不到
解决方案:
application.yml中加入如下配置;
#自定义日志配置文件路径
logging:
config: classpath:logback-custom.xml
path: /home/Desktop/log-file
在logback-custom.xml获取配置的属性:
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<springProperty scope="context" name="LOG_HOME" source="logging.path"/>
</configuration>