sentry的配置
官方的介绍如下:https://docs.sentry.io/platforms/java/configuration/
1、sentry的dsn配置
四种方式:
a、配置文件方式:sentry.properties
dsn=https://examplePublicKey@o0.ingest.sentry.io/0
b、系统变量方式
SENTRY_DSN=https://examplePublicKey@o0.ingest.sentry.io/0
c、java启动参数方式
java -Dsentry.dsn=https://examplePublicKey@o0.ingest.sentry.io/0 -jar app.jar
d、配置中心方式配置
首先在logback.xml中定义好变量,如下:
<?xml version="1.0" encoding="UTF-8"?> <included> <springProperty scope="context" name="log.sentry.dsn" source="log.sentry.dsn" defaultValue=""/> <!-- Configure the Sentry appender, overriding the logging threshold to the WARN level --> <appender name="Sentry" class="io.sentry.logback.SentryAppender"> <options> <dsn>${log.sentry.dsn}</dsn> </options> <!-- Optionally change minimum Event level. Default for Events is ERROR --> <minimumEventLevel>WARN</minimumEventLevel> <!-- Optionally change minimum Breadcrumbs level. Default for Breadcrumbs is INFO --> <minimumBreadcrumbLevel>INFO</minimumBreadcrumbLevel> </appender> <root level="${log.rootLevel}"> <appender-ref ref="Sentry"/> </root> </included>
在分布式配置中心为上面的变量配置值:log.sentry.dsn=https://examplePublicKey@o0.ingest.sentry.io/0
Copied
2、sentry的environment
项目中有多套环境,为了减少sentry的搭建,多套环境服用sentry,此时为了区分不同环境的应用,可以通过sentry中的tag来标记。
四种方式:
a、配置文件方式:sentry.properties
environment=production
b、系统变量方式
SENTRY_ENVIRONMENT=staging
c、java启动参数方式
java -Dsentry.environment=production -jar app.jar
Copied