This example shows how to integrate Sentry into a Java Spring Boot project integrating with logback.
Demonstrates the following features:
- SDK integration
- Configuration
- Releases/Commits
- Event management
- Tags, MDC, additional data
Official Sentry documentation found here: https://docs.sentry.io/platforms/java/guides/logback/
dependency | version |
---|---|
sentry-logback | 4.1.1 |
sentry-spring-boot-starter | 4.1.1 |
Gson | 2.8.6 |
Spring Boot | 4.17.1 |
java | 1.8 |
- Update the Sentry DSN to your project's DSN in application.properties
- Ensure that
SENTRY_AUTH_TOKEN
is set in your ENV variables
Execute the project by running
$ make
Hit the various APIs via another demo (e.g. https://github.com/sentry-demos/react) or tool that calls API (e.g. localhost:8080/handled) such as Postman, Curl, etc.
You can change the log level for events in the application.properties
file.
The minimum event level is set to info
by default which is probably
too verbose.
Follow the steps below to debug mvn: command not found error
:
- Downloaded maven (https://downloads.apache.org/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz) - Binary tar.gz archive link
- Untar and unzip the above tar file to create an archive directory called apache-maven-3.8.1
- Create a directory called Maven at home directory
- Move the apache maven archive directory to Maven directory
- Edit
.zshrc
in your home directory and make the following entries:
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
export M2_HOME=/Users/nandithaembar/Maven/apache-maven-3.8.1
PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin
- Once the changes above are made, start a new terminal and run
make
.
Application.java
- this has the main code for the application and shows
how to add tags and extra data via Sentry.configureScope as well as add
MDC data
application.properties
- include the Sentry project properties here, as well
as set the log levels to send to Sentry
pom.xml
- including the required libraries for the project