jav*_*fan 8 java spring logback spring-boot
在我的spring-boot
应用程序中,我logback
用于记录.应用程序使用外部application.properties
文件来设置特定于环境的应用程序属性,并以选项:开头-spring.config.location=path/to/file
.我希望logback配置从那里读取属性,以便在一个地方管理所有环境属性.
我尝试了这里描述的方法,但由于属性文件不在类路径上,我得到错误:
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.action.PropertyAction - Could not find resource [application.properties]
Run Code Online (Sandbox Code Playgroud)
有什么我想念的吗?
更新:
添加此配置有效:
<property file="path/to/file" />
Run Code Online (Sandbox Code Playgroud)
但我想避免硬编码文件路径.
添加系统环境变量,以便 logback 回退到配置文件的此位置
logback.configurationFile=path/to/config.xml
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3465 次 |
最近记录: |