I looked at the Documentation and some Github examples about adding Sentry logging and monitoring to a Spring project.
Does anyone have an example or a link that can help me with that?
I got it to work.
These are the exact steps you have to follow:
In your pom.xml
, add the following dependency for Sentry. (I am using Logback):
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-logback</artifactId>
<version>1.7.16</version>
</dependency>
For reference (this is just for testing purposes), go in settings, click Client Settings in the SDK setup and get your dsn URL.
After that, make a file in src/resources named sentry.properties
and add the following to it:dsn=<YOUR_DSN_URL>
.
Make a logback.xml
file (if it doesn't already exist) and add the following configuration to it:
<configuration scan="true" debug="true">
<property name="app.name" value="MyApp"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{ISO8601} [%thread] %-5level %logger{40}: %msg%n</pattern>
</encoder>
</appender>
<appender name="Sentry" class="io.sentry.logback.SentryAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="Sentry"/>
</root>
</configuration>