spring-boot - 在 logback.xml 中加载外部属性文件值
问题描述
我的属性文件位于“ 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>
解决方案
经过大量谷歌搜索后,我找到了解决方案。我在 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>
干杯!
推荐阅读
- google-cloud-dataflow - Dataflow 的高可用性和地理冗余
- swift - 如何在自定义视图中显示子组件的 IBInspectable?
- git - 如何在 Git 补丁集之间切换
- prometheus - 有没有办法使用度量/标签值从推送网关中删除?
- firebase - 您如何在水平扩展的应用程序上管理 websocket?
- c# - .NET CORE 未选择 Partial - 默认的 Identity UI 布局需要部分视图
- javascript - 角度项目中的会话存储
- python - 带有附加参数的 Django 模型表单将无法验证
- sed - 如何在 sed 中转义字符串变量?
- python - 带有特殊字符的 Powershell /c (PsExec/EncodedCommand)