我的属性文件在“ E:\config\temp\application-serivce.properties
”中,在该文件中,我提到的日志文件路径为“ logging.path=F:\support\conf\logs
”。
在logback-spring.xml
中我已经提到过,如下
<appender name="FILE-ERROR"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/log.${timestamp}.log</file>
</appender>
但是我仍然无法在属性文件中提到的所需路径中创建日志,这是在logback.xml中加载属性文件的值的任何其他方法。在这里,我使用的是Spring Boot
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
</parent>
[经过大量Google搜索后,我找到了解决方案。我在logback.xml中加入了以下内容和我提到的日志文件路径,例如logger_path=F:\support\conf\logs
<property file="E:\config\temp\application-serivce.properties" />
和
<property name="LOG_PATH" value="${logger_path}" />
<appender name="FILE-ERROR"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/log.${timestamp}.log</file>
</appender>
欢呼!
如果您不想使用绝对路径,也可以在类路径(将其添加到资源文件夹)中作为资源引用。
<property resource="application-serivce.properties" />