- 一、Logback扩展点介绍
- 1、为什么不能用logback.xml配置文件呢?
- 2、扩展点缺点
- 二、指定Profile配置
- 三、环境属性
Spring Boot对Logback做了一些扩展,通过这些拓扩点我们可以用一些更高级的配置,这些拓展点我们可以在logback-spring.xml配置文件中使用。
1、为什么不能用logback.xml配置文件呢?因为标准的logback.xml配置文件加载时间过早,所以不能用相关的扩展点。所以我们需要用logback-spring.xml配置文件或者定义logging.config属性指定配置文件位置。
2、扩展点缺点扩展点不能结合Logback的配置文件自动扫描一起使用。如果配置文件有更改,会出现如下相关的错误日志。
ERROR in ch.qos.logback.core.joran.spi.Interpreter@4:71 - no applicable action for
[springProperty], current ElementPath is [[configuration][springProperty]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@4:71 - no applicable action for
[springProfile], current ElementPath is [[configuration][springProfile]]
二、指定Profile配置
通过
三、环境属性
通过
该标签和Logback中的
如果环境变量中没有指定属性值,可以通过defaultValue属性指定默认值。示例如下:
${fluentHost} ...
备注:source属性格式必须是kebab格式(即:my.property-name)。



