Java
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.
Note
As of June 2017, the old Raven library is no longer maintained. We recommended you migrate to sentry. Check out the migration guide for more information. If you are still using Raven you can find the old documentation here.
Getting Started
Getting started with Sentry is a three step process:
Installation
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.
Configuration
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 sentry.properties):
dsn=https://public:private@host:port/1
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
In code:
import io.sentry.Sentry;
Sentry.init("https://public:private@host:port/1");
Configuration Methods
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.
Next Steps
Resources
- Examples
- Bug Tracker
- Code
- Mailing List
- IRC (irc.freenode.net, #sentry)
- Travis CI