Sentry for Java is a collection of modules provided by Sentry. At its core, Sentry for Java provides a raw client for sending events to Sentry. To begin, we highly recommend you use one of the library or framework integrations listed under Installation. Otherwise, manual usage is another option.
Getting started with Sentry is a three step process:
Once you’ve configured one of the integrations below, you can also use Sentry’s static API in order to do things like record breadcrumbs, set the current user, or manually send events.
Use the configuration below in combination with any of the integrations from above. The configuration will only work after an integration is installed. After that, set your DSN.
Setting the DSN (Data Source Name)
The DSN is the first and most important thing to configure because it tells the SDK where to send events. You can find your project’s DSN in the “Client Keys” section of your “Project Settings” in Sentry.
In a properties file on your filesystem or classpath (defaults to
Via the Java System Properties (not available on Android):
java -Dsentry.dsn=https://public:private@host:port/1 -jar app.jar
Via a System Environment Variable (not available on Android):
SENTRY_DSN=https://public:private@host:port/1 java -jar app.jar
import io.sentry.Sentry; Sentry.init("https://public:private@host:port/1");
There are multiple ways to configure the Java SDK, but all of them take the same options. See the configuration methods documentation for how to use each configuration method and how the option names might differ between them.