> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/iv.-spring-boot-features/26.-logging/26.6.-logback-extensions/26.6.2.-environment-properties.md).

# 26.6.2. Environment属性

`<springProperty>`标签允许你从Spring `Environment`读取属性，以便在Logback中使用。如果你想在logback配置获取`application.properties`中的属性值，该功能就很有用。该标签工作方式跟Logback标准`<property>`标签类似，但不是直接指定`value`值，你需要定义属性的`source`（来自`Environment`），也可以指定存储属性作用域的`scope`。如果`Environment`没有相应属性，你可以通过`defaultValue`设置默认值。下面的例子展示了如何将属性暴露给Logback使用：

```markup
<springProperty scope="context" name="fluentHost" source="myapp.fluentd.host"
        defaultValue="localhost"/>
<appender name="FLUENT" class="ch.qos.logback.more.appenders.DataFluentAppender">
    <remoteHost>${fluentHost}</remoteHost>
    ...
</appender>
```

**注** `source`必须使用短横线隔开（`my.property-name`）的格式指定。但是，属性可以通过relaxed规则添加到`Environment`里。
