# Java Error Monitoring & Performance Monitoring

> Full stack traces with source context for Spring Boot, Logback, and Log4j 2.x. Supports Java 1.8 and above, plus Kotlin and Scala.

**URL:** https://sentry.io/for/java/

---

Actionable insights to solve Java errors.

**Documentation:** [https://docs.sentry.io/platforms/java/](https://docs.sentry.io/platforms/java/)

## Install

### Java

Grab the [Sentry Java SDK](https://github.com/getsentry/sentry-java/):

```xml
<dependency>
  <groupId>io.sentry</groupId>
  <artifactId>sentry</artifactId>
  <version>8.61.0</version>
</dependency>
```

Configure your SDK:

```java
import io.sentry.Sentry;

public class Application {
    public static void main(String[] args) {
        Sentry.init("https://<key>@sentry.io/<project>");

        try {
            runSomething();
        } catch (Exception e) {
            Sentry.captureException(e);
        }
    }
}
```

See the [Java docs](https://docs.sentry.io/platforms/java/) for full setup options.

### Log4j 2

Grab the [Sentry Java SDK](https://github.com/getsentry/sentry-java/):

```xml
<dependency>
  <groupId>io.sentry</groupId>
  <artifactId>sentry-log4j2</artifactId>
  <version>8.61.0</version>
</dependency>
```

Configure your DSN:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" packages="org.apache.logging.log4j.core,io.sentry.log4j2">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
        </Console>
        <Sentry name="Sentry"
                dsn="https://<key>@sentry.io/<project>" />
    </Appenders>
    <Loggers>
        <Root level="info">
            <AppenderRef ref="Sentry"/>
            <AppenderRef ref="Console"/>
        </Root>
    </Loggers>
</Configuration>
```

See the [Log4j 2 docs](https://docs.sentry.io/platforms/java/guides/log4j2/) for full setup options.

### Logback

Grab the [Sentry Java SDK](https://github.com/getsentry/sentry-java/):

```xml
<dependency>
  <groupId>io.sentry</groupId>
  <artifactId>sentry-logback</artifactId>
  <version>8.61.0</version>
</dependency>
```

Configure your DSN:

```xml
<appender name="Sentry" class="io.sentry.logback.SentryAppender">
  <options>
      <!-- NOTE: Replace the test DSN below with YOUR OWN DSN to see the events from this app in your Sentry project/dashboard -->
      <dsn>https://<key>@sentry.io/<project></dsn>
  </options>
</appender>
```

See the [Logback docs](https://docs.sentry.io/platforms/java/guides/logback/) for full setup options.

### Spring

Grab the [Sentry Java SDK](https://github.com/getsentry/sentry-java/):

```xml
<dependency>
  <groupId>io.sentry</groupId>
  <artifactId>sentry-spring</artifactId>
  <version>8.61.0</version>
</dependency>
```

Configure your DSN:

```java
import io.sentry.spring.EnableSentry;
// NOTE: Replace the example DSN below with YOUR OWN DSN to see the events from this app in your Sentry
// project/dashboard
@EnableSentry(dsn = "https://<key>@sentry.io/<project>")
@Configuration
class SentryConfiguration {
}
```

See the [Spring docs](https://docs.sentry.io/platforms/java/guides/spring/) for full setup options.

### Spring Boot

Grab the [Sentry Java SDK](https://github.com/getsentry/sentry-java/):

```xml
<dependency>
  <groupId>io.sentry</groupId>
  <artifactId>sentry-spring-boot-starter</artifactId>
  <version>8.61.0</version>
</dependency>
```

Configure your DSN in `application.properties`:

```properties
sentry.dsn=https://<key>@sentry.io/<project>
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production.
sentry.traces-sample-rate=1.0
```

See the [Spring Boot docs](https://docs.sentry.io/platforms/java/guides/spring-boot/) for full setup options.

## Features

### Java Error Monitoring with Complete Stack Traces

See Java stack trace details like filename and line number so you never have to guess. Filter and group Java exceptions intuitively to eliminate noise. Monitor errors at scale without impacting throughput in production.

### Performance Monitoring Across Services

Quickly identify Java performance issues before they become downtime. View the entire end-to-end distributed trace to see the exact, poor-performing API call and surface any related errors.

### Fill In The Blanks

Expose the important events that led to each Java exception: debug logs, network requests, database queries, past errors.

### See the Full Picture of Any Exception

With Sentry's exceptional exception handling in Java, you can triage quickly based on specific parameters like HTTP request, workflow stage, and hostname for each issue. Set custom tags to recreate the error environment relevant to your app, business concerns, and users.

### Your Logs, Next to the Trace

Route Logback, Log4j 2.x, or java.util.logging output into Sentry and query it beside your [traces](/product/tracing/) and exceptions. The log statements you already emit become searchable context on the exact request that failed.

Learn more about [Logs in Sentry](/product/logs/).

## FAQ

**What is the difference between Sentry and traditional logging?**

Traditional logging provides you with a trail of events. Some of those events are errors, but many times they're simply informational. Sentry is fundamentally different because we focus on exceptions, or in other words, we capture application crashes. We discuss in more detail [here](/vs/logging/) and on our [blog](https://blog.sentry.io/lets-get-ready-to-monitor/).

**How do I connect issues to git commits?**

When Spring Boot is configured to generate Git information every event triggered by Sentry will have a release field set to the current Git commit ID that will enable Monitor Release Health Sentry feature. More details [here](https://docs.sentry.io/platforms/java/guides/spring-boot/#using-git-commit-id-as-the-release).

**How much does Sentry cost?**

You can get started for free. Pricing depends on the number of monthly events, transactions, and attachments that you send Sentry. For more details, visit our [pricing page](/pricing/).

**Which Java versions and frameworks does Sentry support?**

The Sentry Java SDK supports Java 1.8 and above, and works with Kotlin, Scala and other JVM languages. It ships dedicated integrations for [Spring Boot](/for/spring-boot/), [Spring](/for/spring/), Servlet, [Logback](/for/logback/), [Log4j 2.x](/for/log4j2/) and `java.util.logging`, and there is a dedicated [Kotlin](/for/kotlin/) guide.

Gradle and Maven plugins upload source context so your stack traces show the surrounding code, and there is an OpenTelemetry agent if you already run an OTel pipeline.

**Can I send logs to Sentry?**

Yes. Sentry Logs lets you send, view, and query structured logs from your application alongside your errors and traces. Because logs sit next to the error and the trace that produced them, you get the granular context — retries, API failures, internal state — that spans and stack traces alone can miss, without switching tools.

Learn more about [Logs in Sentry](/product/logs/).

**What is Seer, Sentry's AI debugging agent?**

Seer is Sentry's AI debugging agent. It reads the full context Sentry already has — the error, its stack trace, the surrounding trace, logs, and profiles — to find the root cause of an issue and propose a fix. Seer can open a pull request with that fix, hand the work to an external coding agent, or review your PRs before they ship.

Learn more about [Seer](/product/seer/) and [Autofix](/product/seer/autofix/).

---

*Source: [sentry.io/for/java/](https://sentry.io/for/java/)*
