---
title: "Logback Integration"
description: "Learn how to use Sentry's Logback integration with Spring Boot."
url: https://docs.sentry.io/platforms/java/guides/spring-boot/logging-frameworks/logback/
---

# Logback Integration | Sentry for Spring Boot

For the best experience, we recommend using Sentry's Spring Boot integration with the Logback logging framework integration as they work together seamlessly.

##### Logs over Breadcrumbs

By default this integration captures logs as breadcrumbs and error events (great for error context!). But if you need to search and query your logs across your entire application, we recommend enabling the new logs feature. Logs at or above the `sentry.logging.minimum-level` are automatically sent as Sentry Logs when enabled.

## [Installation](https://docs.sentry.io/platforms/java/guides/spring-boot/logging-frameworks/logback.md#installation)

To use Sentry Logback integration in Spring Boot application you must include a dependency to the `sentry-logback` module, then Sentry's Spring Boot Starter will auto-configure `SentryAppender`:

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

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

### [Spring Boot Configuration](https://docs.sentry.io/platforms/java/guides/spring-boot/logging-frameworks/logback.md#spring-boot-configuration)

To send logs to Sentry and have them show up in the Logs section, you need to enable the feature:

```properties
sentry.logs.enabled=true
```

Minimum logging levels for `SentryAppender` can be configured in `application.properties` or `application.yml` file.

```properties
sentry.logging.minimum-event-level=info
sentry.logging.minimum-breadcrumb-level=debug
sentry.logging.minimum-level=debug
```

The default values are:

* `info` or higher to include a log message as breadcrumb.
* `info` or higher will send a log message to Sentry and will show up in the Logs section.
* `error` or higher will send an event to Sentry and will show up in the Issues section.

When `SentryAppender` auto-configuration does not suit your needs, it can be turned off by setting:

```properties
sentry.logging.enabled=false
```

### [XML Configuration](https://docs.sentry.io/platforms/java/guides/spring-boot/logging-frameworks/logback.md#xml-configuration)

If you decide to opt-out from the `application.properties` based Spring Boot logging configuration, and instead configure logging in the `logback-spring.xml` file, the `SentryAppender` can be configured as follows:

```xml
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
  <include
    resource="org/springframework/boot/logging/logback/defaults.xml"
  />
  <include
    resource="org/springframework/boot/logging/logback/console-appender.xml"
  />

  <appender name="SENTRY" class="io.sentry.logback.SentryAppender">
    <minimumLevel>INFO</minimumLevel>
  </appender>

  <root>
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="SENTRY" />
  </root>
</configuration>
```

You do not need to configure your DSN in the Logback configuration file since Sentry is configured from the Spring Boot integration.

However, if errors that may appear during startup should to be sent to Sentry, the DSN must be provided to *both* the Logback and Spring Boot configurations.

## [Mapped Diagnostic Context (MDC)](https://docs.sentry.io/platforms/java/guides/spring-boot/logging-frameworks/logback.md#mapped-diagnostic-context-mdc)

Starting with Sentry Java SDK version 8.24.0, you can use the [`contextTags`](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration/options.md#contextTags) option to include specific properties from the Mapped Diagnostic Context (MDC) as attributes on log entries sent to Sentry.
