【发布时间】:2017-03-22 17:32:18
【问题描述】:
概览:
我在 logback.xml 文件中使用 Sentry 附加程序,我想将大量标签作为参数从 application.properties 文件传递到 logback 配置文件。
logback.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/file-appender.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
<appender name="SENTRY" class="com.getsentry.raven.logback.SentryAppender">
<dsn>
https://e0a61232c92f42ffa34c22914d676a8e:e64f7edc60de490eb004556d2b3fce45@sentry.io/112817
</dsn>
<springProfile name="dev">
<tags>env:dev,app:${app.name},platform:aws</tags>
</springProfile>
<springProfile name="stage">
<tags>env:dev</tags>
</springProfile>
<springProfile name="test">
<tags>env:test</tags>
</springProfile>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
</appender>
<root level="ERROR">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="SENTRY"/>
</root>
</configuration>
application.properties:
security.ignored=/**
logging.level.root = DEBUG
spring.profiles.active=dev
app.name=retailServices
注意: application.properties 中的 spring.profiles.active 属性映射到 logback 配置文件中的 springProfile 标记。
但问题是在 logback.xml 文件中找不到“app.name”属性。如果我将此属性用作系统属性,它可以工作,但我想将它从 application.properties 传递给配置文件。
因此,我们将非常感谢任何解决方案、反馈和想法。
【问题讨论】:
标签: spring-boot logback sentry