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:

  1. ./mvnw quarkus:add-extension -Dextensions="logging-sentry"

This will add the following to your pom.xml:

  1. <dependency>
  2. <groupId>io.quarkus</groupId>
  3. <artifactId>quarkus-logging-sentry</artifactId>
  4. </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:

  1. 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 *:

  1. 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)

  1. quarkus.log.sentry=true
  2. quarkus.log.sentry.dsn=https://abcd@sentry.io/1234
  3. 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)

  1. quarkus.log.sentry=true
  2. quarkus.log.sentry.dsn=https://abcd@sentry.io/1234
  3. quarkus.log.sentry.level=ERROR
  4. quarkus.log.sentry.in-app-packages=org.example

Configuration Reference

This extension is configured through the standard application.properties file.