如何让 Spring Boot 根据配置文件在我的 logback.xml
中设置属性?
这是我尝试过的:
我有一个application-default.properties
:
log.dir=/var/log
还有一个application-development.properties
,其中:
log.dir=target
我想将其传递到我的 logback.xml
中:
<property scope="context" name="logDir" value="${log.dir}" />
使用开发配置文件运行-Dspring.profiles.active=development
我遇到logback问题:
RollingFileAppender - Active log file name: log.dir_IS_UNDEFINED/My.log
最佳答案
在 Spring boot 中(在 1.4.1 上测试),我建议:
应用程序默认属性:
logging.file=/var/log/My.log
应用程序开发.属性:
logging.file=/target/My.log
logback-spring.xml:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
</configuration>
关于java - spring-boot logback.xml 属性取决于配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37685773/