Quarkus - Logging to Sentry
This guide explains how to configure Quarkus to log to Sentry.
Description
Sentry is a really easy way to be notified of errors happening in your Quarkus application.
It is a self-hosted and cloud-based error monitoring that helps software teams discover, triage, and prioritize errors in real-time.
They offer a free starter price for cloud-based or you can self host it for free.
Sentry’s Java SDK is open source, but recently sentry.io changed the license for their backend to the non-open source BSL license. This might or might not be an issue for your project and product. |
Configuration
To start with, you need to get a Sentry DSN either by creating a Sentry account or installing your own self-hosted Sentry.
In order to configure Sentry logging, add the logging-sentry
extension to your project by running the following command in your project base directory:
./mvnw quarkus:add-extension -Dextensions="logging-sentry"
This will add the following to your pom.xml
:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-logging-sentry</artifactId>
</dependency>
“In Application” Stack Frames
Sentry differentiates stack frames that are directly related to your application (“in application”) from stack frames that come from other packages such as the standard library, frameworks, or other dependencies. The difference is visible in the Sentry web interface where only the “in application” frames are displayed by default.
You can configure which package prefixes your application uses with the in-app-packages
option, which takes a comma separated list of packages:
quarkus.log.sentry.in-app-packages=com.mycompany,com.other.name
If you don’t want to use this feature but want to disable the warning, simply set it to *
:
quarkus.log.sentry.in-app-packages=*
Example
All errors and warnings occurring in any of the packages will be sent to Sentry with DSN [https://abcd@sentry.io/1234](https://abcd@sentry.io/1234)
quarkus.log.sentry=true
quarkus.log.sentry.dsn=https://abcd@sentry.io/1234
quarkus.log.sentry.in-app-packages=*
All errors occurring in the package org.example
will be sent to Sentry with DSN [https://abcd@sentry.io/1234](https://abcd@sentry.io/1234)
quarkus.log.sentry=true
quarkus.log.sentry.dsn=https://abcd@sentry.io/1234
quarkus.log.sentry.level=ERROR
quarkus.log.sentry.in-app-packages=org.example
Configuration Reference
This extension is configured through the standard application.properties
file.