spring-boot logback.xml属性,具体取决于配置文件

时间:2016-06-07 17:34:37

标签: java spring spring-boot logback

如何根据配置文件让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

1 个答案:

答案 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>