---
title: "Extended Configuration"
description: "Learn more about how to configure the SDK. These options are set when the SDK is first initialized, passed to the init method as an object."
url: https://docs.sentry.io/platforms/java/guides/spring-boot/configuration/
---

# Extended Configuration | Sentry for Spring Boot

## [Setting the DSN (Data Source Name)](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#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. It can be configured in multiple ways. Explanations of the [configuration methods are detailed below](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#configuration-methods).

In a properties file on your filesystem or classpath (defaults to `sentry.properties`):

`sentry.properties`

```text
dsn=___PUBLIC_DSN___
```

Via the Java System Properties *(not available on Android)*:

```bash
java -Dsentry.dsn=___PUBLIC_DSN___ -jar app.jar
```

Via a System Environment Variable *(not available on Android)*:

```bash
SENTRY_DSN=___PUBLIC_DSN___ java -jar app.jar
```

In code:

```java
import io.sentry.Sentry;

Sentry.init(options -> {
  options.setDsn("___PUBLIC_DSN___");
});
```

When multiple configuration ways are used, options are resolved in the following order:

* system properties
* environment variables
* `sentry.properties` file which location is resolved from the system property `sentry.properties.file`
* `sentry.properties` file which location is resolved from the environment `SENTRY_PROPERTIES_FILE`
* `sentry.properties` located in the root of the classpath
* options provided in Java code

## [Configuration methods](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#configuration-methods)

There are multiple ways to configure the Java SDK, but all of them take the same options. See below for how to use each configuration method and how the option names might differ between them.

To enable loading configuration from the properties file, system properties or environment variables, `enableExternalConfiguration` has to be set to `true` on `SentryOptions`:

```java
import io.sentry.Sentry;

Sentry.init(options -> {
  options.setEnableExternalConfiguration(true);
});
```

### [Configuration via properties file](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#configuration-via-properties-file)

The Java SDK can be configured via a [.properties file](https://en.wikipedia.org/wiki/.properties) that is located on the filesystem or in your application’s classpath. By default the SDK will look for a `sentry.properties` file in the application’s current working directory or in the root of your classpath. In most server side applications the default directory to add resources to your classpath is `src/main/resources/`, and on Android the default is `app/src/main/resources/`. You can override the location of the properties file by using either the `sentry.properties.file` Java System Property or the `SENTRY_PROPERTIES_FILE` System Environment Variable.

Because this file is often bundled with your application, the values cannot be changed easily once your application has been packaged. For this reason, the properties file is useful for setting defaults or options that you don’t expect to change often. The properties file is the last place checked for each option value, so runtime configuration (described below) will override it if available.

Option names in the property file exactly match the examples given below. For example, to configure the environment, in your properties file:

```properties
environment=production
```

### [Configuration via the runtime environment](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#configuration-via-the-runtime-environment)

This is the most flexible method for configuring the Sentry client because it can be easily changed based on the environment you run your application in. *Neither Java System Properties or System Environment Variables are available for Android applications. Please configure Sentry for Android via code or the properties file.*

Two methods are available for runtime configuration, checked in this order: Java System Properties and System Environment Variables.

Java System Property option names are exactly like the examples given below except that they are prefixed with `sentry.`. For example, to enable sampling:

```bash
java -Dsentry.environment=production -jar app.jar
```

System Environment Variable option names require that you replace the `.` with `_`, capitalize them, and add a `SENTRY_` prefix. For example, to enable sampling:

```bash
SENTRY_ENVIRONMENT=production
```

## [Options](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#options)

The following options can all be configured as described above: via a `sentry.properties` file, via Java System Properties, via System Environment variables.

### [Release](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#release)

To set the application version that will be sent with each event, use the `release` option:

```properties
release=my-project-name@2.3.12
```

### [Distribution](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#distribution)

To set the application distribution that will be sent with each event, use the `dist` option:

```properties
release=my-project-name@2.3.12
dist=x86
```

The distribution is only useful (and used) if the `release` is also set.

### [Environment](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#environment)

To set the application environment that will be sent with each event, use the `environment` option:

```properties
environment=staging
```

### [Server Name](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#server-name)

To set the server name that will be sent with each event, use the `servername` option:

```properties
servername=host1
```

### [Tags](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#tags)

To set the common tags that will be sent with each event, use the `tags` options:

```properties
tags.first_tag=first-tag-value
tags.second_tag=second-tag-value
```

### [In App Includes](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#in-app-includes)

To set the in-app-includes that will be sent with each event, use the `in-app-includes` option:

```properties
in-app-includes=com.mycompany,com.other.name
```

### [In App Excludes](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#in-app-excludes)

To set the in-app-excludes that will be sent with each event, use the `in-app-excludes` option:

```properties
in-app-excludes=host1
```

### [Ignored Exceptions For Type](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#ignored-exceptions-for-type)

To set exceptions that will be filtered out before sending to Sentry, use the `ignored-exceptions-for-type` option:

```properties
ignored-exceptions-for-type=java.lang.RuntimeException,java.lang.IllegalStateException
```

### [Traces Sample Rate](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#traces-sample-rate)

To set the traces sample rate, use the `traces-sample-rate` option:

```properties
traces-sample-rate=0.2
```

### [Tracing Origins](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#tracing-origins)

To set tracing origins, use the `trace-propagation-targets` option:

```properties
trace-propagation-targets=localhost,^(http|https)://api\\..*$
```

### [Debug](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#debug)

To set Sentry in the debug mode, use the `debug` option:

```properties
debug=true
```

### [Disable Sentry](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#disable-sentry)

To disable Sentry, use the `enabled` option:

```properties
enabled=false
```

## [Configuring Timeouts](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#configuring-timeouts)

It’s possible to manually set the connection timeouts length with `connectionTimeoutMillis` and `readTimeoutMillis`:

```java
import io.sentry.Sentry;

Sentry.init(options -> {
  options.setConnectionTimeoutMillis(10000);
  options.setReadTimeoutMillis(10000);
});
```

## [Using a Proxy](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#using-a-proxy)

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

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

```bash
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” \
  \
  MyApp
```

See [Java Networking and Proxies](http://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html) for more information about the proxy properties.

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

```properties
proxy.host=proxy.example.com
# optional
proxy.port=8080 # default 80
proxy.user=proxy-user
proxy.pass=proxy-password
```

## [Configuring Offline Caching](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#configuring-offline-caching)

The SDK can store events on the disk in case of network errors, and send them to Sentry on another SDK init if the Sentry server is reachable.

To turn on offline caching, set `cacheDirPath` and add `SendCachedEnvelopeFireAndForgetIntegration` to Sentry options:

```java
import io.sentry.SendCachedEnvelopeFireAndForgetIntegration;
import io.sentry.SendFireAndForgetEnvelopeSender;
import io.sentry.Sentry;

Sentry.init(options -> {
  ...
  options.setCacheDirPath("/disk/path");
  options.addIntegration(
    new SendCachedEnvelopeFireAndForgetIntegration(
      new SendFireAndForgetEnvelopeSender(options::getCacheDirPath)
    )
  );
})
```

## [Client reports](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration.md#client-reports)

To turn off sending of client reports, use the [`sendClientReports`](https://docs.sentry.io/platforms/java/configuration/options.md#sendClientReports) option:

```properties
send-client-reports=false
```

## Pages in this section

- [Options](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration/options.md)
- [Environments](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration/environments.md)
- [Releases & Health](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration/releases.md)
- [Sampling](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration/sampling.md)
- [Filtering](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration/filtering.md)
- [Shutdown and Draining](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration/draining.md)
- [Using a BOM](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration/bill-of-materials.md)
