From e0a040ded218814b7d2ee81bbbc4496e6b3342d8 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Tue, 15 Sep 2026 14:40:44 +0200 Subject: [PATCH 1/4] log4j auto configuration docs --- .../spring-boot/logging-frameworks/log4j2.mdx | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx b/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx index 746293f572de8b..650433a299595d 100644 --- a/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx +++ b/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx @@ -43,8 +43,41 @@ To send logs to Sentry and have them show up in the Logs section, you need to en sentry.logs.enabled=true ``` +For Spring Boot 3 and 4, Sentry can register `SentryAppender` for you once the application context refreshes. This auto-configuration is opt-in: + +```properties +sentry.logging.enabled=true +``` + +Auto-configuration only runs when Log4j 2 Core is the active logging backend. If Log4j 2 API calls are routed through SLF4J to another backend, such as Logback, the appender isn't added. + +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. + +The appender is added to the root logger by default. To attach it to specific loggers instead, configure their names: + +```properties +sentry.logging.loggers[0]=com.example.orders +sentry.logging.loggers[1]=com.example.payments +``` + +Use non-overlapping logger names. Log4j 2 loggers are additive by default, so attaching the appender to both a logger and one of its ancestors can send the same log entry twice. + ### XML Configuration +Spring Boot 2 doesn't support `SentryAppender` auto-configuration, and errors logged before the Spring context refreshes aren't captured by it. In both cases, configure the appender yourself and leave `sentry.logging.enabled` unset. + [Follow the guide on configuring Log4j 2 with Spring Boot](https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-configure-log4j-for-logging) and configure `SentryAppender` in the `log4j2.xml` file: ```xml From 20077fe550d31a303e5fbf2b433a5c0ce3f1f997 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Fri, 18 Sep 2026 10:21:39 +0200 Subject: [PATCH 2/4] make the link to the spring-boot guide on how to setup log4j more prominent --- .../guides/spring-boot/logging-frameworks/log4j2.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx b/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx index 650433a299595d..bfa87f208a575b 100644 --- a/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx +++ b/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx @@ -13,7 +13,9 @@ By default this integration captures logs as breadcrumbs and error events (great ## Installation -To use Sentry's Log4j 2 integration in Spring Boot application, you must include a dependency to the `sentry-log4j2` module: +Spring Boot uses Logback by default, so first [follow the guide on configuring Log4j 2 with Spring Boot](https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-configure-log4j-for-logging) to make Log4j 2 the active logging backend. + +Then, to use Sentry's Log4j 2 integration in Spring Boot application, you must include a dependency to the `sentry-log4j2` module: ```xml {tabTitle:Maven} @@ -49,7 +51,7 @@ For Spring Boot 3 and 4, Sentry can register `SentryAppender` for you once the a sentry.logging.enabled=true ``` -Auto-configuration only runs when Log4j 2 Core is the active logging backend. If Log4j 2 API calls are routed through SLF4J to another backend, such as Logback, the appender isn't added. +If Log4j 2 isn't the active logging backend, the appender isn't added. Minimum logging levels for `SentryAppender` can be configured in `application.properties` or `application.yml` file. @@ -76,9 +78,7 @@ Use non-overlapping logger names. Log4j 2 loggers are additive by default, so at ### XML Configuration -Spring Boot 2 doesn't support `SentryAppender` auto-configuration, and errors logged before the Spring context refreshes aren't captured by it. In both cases, configure the appender yourself and leave `sentry.logging.enabled` unset. - -[Follow the guide on configuring Log4j 2 with Spring Boot](https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-configure-log4j-for-logging) and configure `SentryAppender` in the `log4j2.xml` file: +Spring Boot 2 doesn't support `SentryAppender` auto-configuration, and errors logged before the Spring context refreshes aren't captured by it. In both cases, leave `sentry.logging.enabled` unset and configure `SentryAppender` in the `log4j2.xml` file: ```xml From 65e862836c4f76249d1b16c24ec61c40b9ccf793 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Mon, 21 Sep 2026 09:14:48 +0200 Subject: [PATCH 3/4] update link to spring boot docs --- .../java/guides/spring-boot/logging-frameworks/log4j2.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx b/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx index bfa87f208a575b..037c2e1aee3cca 100644 --- a/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx +++ b/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx @@ -13,7 +13,7 @@ By default this integration captures logs as breadcrumbs and error events (great ## Installation -Spring Boot uses Logback by default, so first [follow the guide on configuring Log4j 2 with Spring Boot](https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-configure-log4j-for-logging) to make Log4j 2 the active logging backend. +Spring Boot uses Logback by default, so first [follow the guide on configuring Log4j 2 with Spring Boot](https://docs.spring.io/spring-boot/how-to/logging.html#howto.logging.log4j) to make Log4j 2 the active logging backend. Then, to use Sentry's Log4j 2 integration in Spring Boot application, you must include a dependency to the `sentry-log4j2` module: From bebb339eabcf48a07988de7cb51c6e22d7de3ae5 Mon Sep 17 00:00:00 2001 From: Alex Krawiec Date: Wed, 23 Sep 2026 14:24:49 -0700 Subject: [PATCH 4/4] Update docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx --- .../java/guides/spring-boot/logging-frameworks/log4j2.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx b/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx index 037c2e1aee3cca..e5f5e55e960ccd 100644 --- a/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx +++ b/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx @@ -15,7 +15,7 @@ By default this integration captures logs as breadcrumbs and error events (great Spring Boot uses Logback by default, so first [follow the guide on configuring Log4j 2 with Spring Boot](https://docs.spring.io/spring-boot/how-to/logging.html#howto.logging.log4j) to make Log4j 2 the active logging backend. -Then, to use Sentry's Log4j 2 integration in Spring Boot application, you must include a dependency to the `sentry-log4j2` module: +Then, to use Sentry's Log4j 2 integration in your Spring Boot application, you must include a dependency to the `sentry-log4j2` module: ```xml {tabTitle:Maven}