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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM