A Sentry client for Java and other JVM languages.
Java Python



Build Status Maven Central

Raven is the Java client for Sentry. Raven relies on the most popular logging libraries to capture and convert logs before sending details to a Sentry instance.

While it's strongly recommended to use one of the supported logging frameworks to capture and send messages to Sentry, it is also possible to do so manually with the main project raven.

Raven supports both HTTP and HTTPS as transport protocols to the Sentry instance.

Support for Google App Engine is provided in raven-appengine


Stable versions of Raven are available on the central Maven Repository under the com.getsentry groupId. (NOTE: This is change from the previous net.kencochrane groupId)

Please see individual module READMEs for more information.

Snapshot versions

Newer (but less stable) versions (AKA snapshots) are available in Sonatype's snapshot repository.

To use it with maven, add the following repository:

    <name>Sonatype Nexus Snapshots</name>


Raven also works on Android. For integration details, see the raven-android README.

HTTP Request Context

If the runtime environment utilizes Servlets, events that are created during the processing of an HTTP request will include additional contextual data about that active request, such as the URL, method, parameters, and other data. (This feature requires version 2.4 the Servlet API.)

Connection and protocol

It is possible to send events to Sentry over different protocols, depending on the security and performance requirements.


The most common way to send events to Sentry is via HTTP, this can be done by using a DSN of this form:


If not provided, the port will default to 80.


It is possible to use an encrypted connection to Sentry via HTTPS:


If not provided, the port will default to 443.

HTTPS (naive)

If the certificate used over HTTPS is a wildcard certificate (which is not handled by every version of Java), and the certificate isn't added to the truststore, you can add a protocol setting to tell the client to be naive and ignore hostname verification:


Proxying HTTP(S) connections

If your application needs to send outbound requests through an HTTP proxy, you can configure the proxy information via JVM networking properties or as part of the Sentry DSN.

For example, using JVM networking properties (affects the entire JVM process),

java \
  # if you are using the HTTP protocol \
  -Dhttp.proxyHost=proxy.example.com \
  -Dhttp.proxyPort=8080 \
  # if you are using the HTTPS protocol \
  -Dhttps.proxyHost=proxy.example.com \
  -Dhttps.proxyPort=8080 \
  # relevant to both HTTP and HTTPS
  -Dhttp.nonProxyHosts=”localhost|host.example.com” \

See Java Networking and Proxies for more information about the proxy properties.

Alternatively, using the Sentry DSN (only affects the Sentry HTTP client, useful inside shared application containers),



It is possible to enable some options by adding data to the query string of the DSN:


Some options do not require a value, just being declared signifies that the option is enabled.

Async connection

In order to avoid performance issues due to a large amount of logs being generated or a slow connection to the Sentry server, an asynchronous connection is set up, using a low priority thread pool to submit events to Sentry.

To disable the async mode, add raven.async=false to the DSN:


Graceful Shutdown (advanced)

In order to shutdown the asynchronous connection gracefully, a ShutdownHook is created. By default, the asynchronous connection is given 1 second to shutdown gracefully, but this can be adjusted via raven.async.shutdowntimeout (represented in milliseconds):


The special value -1 can be used to disable the timeout and wait indefinitely for the executor to terminate.

The ShutdownHook could lead to memory leaks in an environment where the life cycle of Raven doesn't match the life cycle of the JVM.

An example would be in a JEE environment where the application using Raven could be deployed and undeployed regularly.

To avoid this behaviour, it is possible to disable the graceful shutdown. This might lead to some log entries being lost if the log application doesn't shut down the Raven instance nicely.

The option to do so is raven.async.gracefulshutdown:


Queue size (advanced)

The default queue used to store unprocessed events is limited to 50 items. Additional items added once the queue is full are dropped and never sent to the Sentry server. Depending on the environment (if the memory is sparse) it is important to be able to control the size of that queue to avoid memory issues.

It is possible to set a maximum with the option raven.async.queuesize:


This means that if the connection to the Sentry server is down, only the 100 most recent events will be stored and processed as soon as the server is back up.

The special value -1 can be used to enable an unlimited queue. Beware that network connectivity or Sentry server issues could mean your process will run out of memory.

Threads count (advanced)

By default the thread pool used by the async connection contains one thread per processor available to the JVM.

It's possible to manually set the number of threads (for example if you want only one thread) with the option raven.async.threads:


Threads priority (advanced)

In most cases sending logs to Sentry isn't as important as an application running smoothly, so the threads have a minimal priority.

It is possible to customise this value to increase the priority of those threads with the option raven.async.priority:


Buffering to disk upon network error

Raven can be configured to write events to a specified directory on disk anytime communication with the Sentry server fails with the raven.buffer.dir option. If the directory doesn't exist, Raven will attempt to create it on startup and may therefore need write permission on the parent directory. Raven always requires write permission on the buffer directory itself.


The maximum number of events that will be stored on disk defaults to 50, but can also be configured with the option raven.buffer.size:


If a buffer directory is provided, a background thread will periodically attempt to re-send the events that are found on disk. By default it will attempt to send events every 60 seconds. You can change this with the raven.buffer.flushtime option (in milliseconds):


Graceful Shutdown (advanced)

In order to shutdown the buffer flushing thread gracefully, a ShutdownHook is created. By default, the buffer flushing thread is given 1 second to shutdown gracefully, but this can be adjusted via raven.buffer.shutdowntimeout (represented in milliseconds):


The special value -1 can be used to disable the timeout and wait indefinitely for the executor to terminate.

The ShutdownHook could lead to memory leaks in an environment where the life cycle of Raven doesn't match the life cycle of the JVM.

An example would be in a JEE environment where the application using Raven could be deployed and undeployed regularly.

To avoid this behaviour, it is possible to disable the graceful shutdown by setting the raven.buffer.gracefulshutdown option:


Inapp classes

Sentry differentiate in_app stack frames (which are directly related to your application) and the "not in_app" ones. This difference is visible in the Sentry web interface where only the in_app frames are displayed by default.

Same frame as enclosing exception

Raven can use the in_app system to hide frames in the context of chained exceptions.

Usually when a StackTrace is printed, the result looks like this:

HighLevelException: MidLevelException: LowLevelException
        at Main.a(Main.java:13)
        at Main.main(Main.java:4)
Caused by: MidLevelException: LowLevelException
        at Main.c(Main.java:23)
        at Main.b(Main.java:17)
        at Main.a(Main.java:11)
        ... 1 more
Caused by: LowLevelException
        at Main.e(Main.java:30)
        at Main.d(Main.java:27)
        at Main.c(Main.java:21)
        ... 3 more

Some frames are replaced by the ... N more line as they are the same frames as in the enclosing exception.

To enable a similar behaviour from Raven use the raven.stacktrace.hidecommon option.


Hide frames based on the class name

Raven can also mark some frames as in_app based on the name of the class.

This can be used to hide parts of the stacktrace that are irrelevant to the problem for example the stack frames in the java.util package will not help determining what the problem was and will just create a longer stacktrace.

Currently this is not configurable (see #49) and some packages are ignored by default:

  • com.sun.*
  • java.*
  • javax.*
  • org.omg.*
  • sun.*
  • junit.*
  • com.intellij.rt.*


By default the content sent to Sentry is compressed and encoded in base64 before being sent. However, compressing and encoding the data adds a small CPU and memory hit which might not be useful if the connection to Sentry is fast and reliable.

Depending on the limitations of the project (e.g. a mobile application with a limited connection, Sentry hosted on an external network), it can be useful to compress the data beforehand or not.

It's possible to manually enable/disable the compression with the option raven.compression


Max message size

By default only the first 1000 characters of a message will be sent to the server. This can be changed with the raven.maxmessagelength option.


Timeout (advanced)

A timeout is set to avoid blocking Raven threads because establishing a connection is taking too long.

It's possible to manually set the timeout length with raven.timeout (in milliseconds):


Custom RavenFactory

At times, you may require custom functionality that is not included in raven-java already. The most common way to do this is to create your own RavenFactory instance as seen in the example below.

public class MyRavenFactory extends DefaultRavenFactory {

    public Raven createRavenInstance(Dsn dsn) {
        Raven raven = new Raven();

        Create and use the ForwardedAddressResolver, which will use the
        X-FORWARDED-FOR header for the remote address if it exists.
        ForwardedAddressResolver forwardedAddressResolver = new ForwardedAddressResolver();
        raven.addBuilderHelper(new HttpEventBuilderHelper(forwardedAddressResolver));

        return raven;


You'll need to add a ServiceLoader provider file to your project at src/main/resources/META-INF/services/com.getsentry.raven.RavenFactory that contains the name of your class so that it will be considered as a candidate RavenFactory. For an example, see how we configure the DefaultRavenFactory itself.

Finally, see the README for the logger integration you use to find out how to configure it to use your custom RavenFactory.