如何根据配置文件让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
运行我收到了回溯问题:
RollingFileAppender - Active log file name: log.dir_IS_UNDEFINED/My.log
答案 0 :(得分:0)
在Spring启动(在1.4.1上测试),我建议:
application-default.properties:
logging.file=/var/log/My.log
application-development.properties:
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>