springboot logback no applicable action for [springProfile], current ElementPath is [[configuration]
在springboot项目里使用logback报如下错误14:25:46,762 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@3:72 - no applicable action for [springProperty], current ElementPathis [[configuration][springProperty]]1
·
在springboot项目里使用logback报如下错误
14:25:46,762 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@3:72 - no applicable action for [springProperty], current ElementPath is [[configuration][springProperty]]
14:25:46,762 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@4:81 - no applicable action for [springProperty], current ElementPath is [[configuration][springProperty]]
解决方式
官方提供了解决方案:
-
方法一
将logback配置文件名由
logback.xml
改为logback-spring.xml
-
方法二
在项目配置文件,如
application.properties
中指定logging.config=classpath:logback.xml
原因
springboot提供了一些logback扩展功能。如果日志配置文件的名称是logback.xml,logback配置会先于Spring之前加载,导致无法使用扩展功能。
如果logback配置文件中使用的变量是springboot项目中的,则过早加载logback配置文件会获取不到这些变量。比如logback.xml中有这样的配置
<springProperty scope="context" name="LOG_PATH" source="log.path"/>
log.path
是配置在 application.properties 中的,如果 logback.xml 先于application.properties 加载,自然因得不到log.path
而报错。
更多推荐
已为社区贡献1条内容
所有评论(0)