From de8066a74ca4a4b839b020faf309afaa5373d619 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Mon, 1 Dec 2025 09:42:21 +0100 Subject: [PATCH 1/4] add logs feature toggle, in spring boot logging-frameworks highlight logs --- .../guides/spring-boot/logging-frameworks.mdx | 40 +++++++++++-------- .../getting-started-config/java.log4j2.mdx | 18 ++++++++- .../getting-started-config/java.logback.mdx | 16 ++++++++ .../java.spring-boot.mdx | 11 +++++ .../opentelemetry/java.mdx | 3 ++ .../getting-started-install/java.log4j2.mdx | 2 +- .../getting-started-install/java.logback.mdx | 2 +- .../java.spring-boot.mdx | 2 +- 8 files changed, 73 insertions(+), 21 deletions(-) diff --git a/docs/platforms/java/guides/spring-boot/logging-frameworks.mdx b/docs/platforms/java/guides/spring-boot/logging-frameworks.mdx index 5fc7aaee7f4997..e1765d5c7a93fc 100644 --- a/docs/platforms/java/guides/spring-boot/logging-frameworks.mdx +++ b/docs/platforms/java/guides/spring-boot/logging-frameworks.mdx @@ -6,20 +6,18 @@ description: "Learn more about using one of our logging integrations with Sentry For the best experience, we recommend using Sentry's Spring Boot integration with one of the logging framework integrations as they work together seamlessly. -### Logback + -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`: +By default these integrations capture 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. -```xml {tabTitle:Maven} - - io.sentry - sentry-logback - {{@inject packages.version('sentry.java.logback', '4.2.0') }} - -``` + -```groovy {tabTitle:Gradle} -implementation 'io.sentry:sentry-logback:{{@inject packages.version('sentry.java.logback', '4.2.0') }}' +## 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. @@ -36,16 +34,26 @@ The default values are: - `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. -To send logs to Sentry and have them show up in the Logs section, you need to enable the feature: +When `SentryAppender` auto-configuration does not suit your needs, it can be turned off by setting: ```properties -sentry.logs.enabled=true +sentry.logging.enabled=false ``` -When `SentryAppender` auto-configuration does not suit your needs, it can be turned off by setting: +### Logback -```properties -sentry.logging.enabled=false +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 {tabTitle:Maven} + + io.sentry + sentry-logback + {{@inject packages.version('sentry.java.logback', '4.2.0') }} + +``` + +```groovy {tabTitle:Gradle} +implementation 'io.sentry:sentry-logback:{{@inject packages.version('sentry.java.logback', '4.2.0') }}' ``` 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: diff --git a/platform-includes/getting-started-config/java.log4j2.mdx b/platform-includes/getting-started-config/java.log4j2.mdx index 73bbfc870b5134..ad63de687fce74 100644 --- a/platform-includes/getting-started-config/java.log4j2.mdx +++ b/platform-includes/getting-started-config/java.log4j2.mdx @@ -71,6 +71,9 @@ If the DSN is not present in the `log4j2.xml` configuration, Sentry will attempt # Add data like request headers and IP for users, # see https://docs.sentry.io/platforms/java/guides/log4j2/data-management/data-collected/ for more info send-default-pii=true +// ___PRODUCT_OPTION_START___ logs +logs.enabled=true +// ___PRODUCT_OPTION_END___ logs ``` @@ -80,6 +83,9 @@ Two log levels are used to configure this integration, as illustrated below in t 1. Configure the lowest level required for a log message to become an event (`minimumEventLevel`) sent to Sentry. 2. Configure the lowest level a message has to be to become a breadcrumb (`minimumBreadcrumbLevel`) + +3. Configure the lowest level a message has to be to be sent as Sentry Log (`minimumLevel`). + @@ -96,7 +102,11 @@ Breadcrumbs are kept in memory (by default the last 100 records) and are sent wi + minimumEventLevel="WARN" + + minimumLevel="DEBUG" + + /> ``` @@ -105,6 +115,10 @@ Breadcrumbs are kept in memory (by default the last 100 records) and are sent wi + minimumEventLevel="WARN" + + minimumLevel="DEBUG" + + /> ``` diff --git a/platform-includes/getting-started-config/java.logback.mdx b/platform-includes/getting-started-config/java.logback.mdx index 4f3b5677405002..1fdfe1b3dc621a 100644 --- a/platform-includes/getting-started-config/java.logback.mdx +++ b/platform-includes/getting-started-config/java.logback.mdx @@ -25,6 +25,11 @@ The `ConsoleAppender` is provided only as an example of a non-Sentry appender se ___PUBLIC_DSN___ true + // ___PRODUCT_OPTION_START___ logs + + true + + // ___PRODUCT_OPTION_END___ logs @@ -87,6 +92,9 @@ Two log levels are used to configure this integration: 1. Configure the lowest level required for a log message to become an event (`minimumEventLevel`) sent to Sentry. 2. Configure the lowest level a message has to be to become a breadcrumb (`minimumBreadcrumbLevel`). + +3. Configure the lowest level a message has to be to be sent as Sentry Log (`minimumLevel`). + @@ -110,6 +118,10 @@ Breadcrumbs are kept in memory (by default the last 100 records) and are sent wi WARN DEBUG + // ___PRODUCT_OPTION_START___ logs + + DEBUG + // ___PRODUCT_OPTION_END___ logs ``` @@ -121,6 +133,10 @@ Breadcrumbs are kept in memory (by default the last 100 records) and are sent wi WARN DEBUG + // ___PRODUCT_OPTION_START___ logs + + DEBUG + // ___PRODUCT_OPTION_END___ logs ``` diff --git a/platform-includes/getting-started-config/java.spring-boot.mdx b/platform-includes/getting-started-config/java.spring-boot.mdx index 8dfcda7535ed25..555ee298f968db 100644 --- a/platform-includes/getting-started-config/java.spring-boot.mdx +++ b/platform-includes/getting-started-config/java.spring-boot.mdx @@ -22,6 +22,11 @@ sentry.traces-sample-rate=1.0 sentry.profile-session-sample-rate=1.0 sentry.profile-lifecycle=TRACE // ___PRODUCT_OPTION_END___ profiling +// ___PRODUCT_OPTION_START___ logs + +# Enable logs +sentry.logs.enabled: true +// ___PRODUCT_OPTION_END___ logs ``` ```yaml {filename:application.yml} @@ -44,6 +49,12 @@ sentry: profileSessionSampleRate: 1.0 profileLifecycle: TRACE // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + # Enable logs + logs: + enabled: true + // ___PRODUCT_OPTION_END___ logs ``` By default, only unhandled exceptions are sent to Sentry. This behavior can be tuned through configuring the `sentry.exception-resolver-order` property. For example, setting it to `-2147483647` (the value of `org.springframework.core.Ordered#HIGHEST_PRECEDENCE`) ensures exceptions that have been handled by exception resolvers with higher order are sent to Sentry - including ones handled by `@ExceptionHandler` annotated methods. diff --git a/platform-includes/getting-started-config/opentelemetry/java.mdx b/platform-includes/getting-started-config/opentelemetry/java.mdx index de03b54463cc09..7770dd5d258b48 100644 --- a/platform-includes/getting-started-config/opentelemetry/java.mdx +++ b/platform-includes/getting-started-config/opentelemetry/java.mdx @@ -10,6 +10,9 @@ send-default-pii=true # ___PRODUCT_OPTION_START___ performance traces-sample-rate=1.0 # ___PRODUCT_OPTION_END___ performance +// ___PRODUCT_OPTION_START___ logs +logs.enabled=true +// ___PRODUCT_OPTION_END___ logs // ___PRODUCT_OPTION_START___ profiling # Enable profiling diff --git a/platform-includes/getting-started-install/java.log4j2.mdx b/platform-includes/getting-started-install/java.log4j2.mdx index 38b873980673e7..53532e6e46d156 100644 --- a/platform-includes/getting-started-install/java.log4j2.mdx +++ b/platform-includes/getting-started-install/java.log4j2.mdx @@ -1,5 +1,5 @@ ```xml {tabTitle:Maven Plugin}{filename:pom.xml} diff --git a/platform-includes/getting-started-install/java.logback.mdx b/platform-includes/getting-started-install/java.logback.mdx index 1f9d275a3cc916..fb588c9f355ea6 100644 --- a/platform-includes/getting-started-install/java.logback.mdx +++ b/platform-includes/getting-started-install/java.logback.mdx @@ -1,5 +1,5 @@ ```xml {tabTitle:Maven Plugin}{filename:pom.xml} diff --git a/platform-includes/getting-started-install/java.spring-boot.mdx b/platform-includes/getting-started-install/java.spring-boot.mdx index edb95bc06580c2..cb8a54531752c7 100644 --- a/platform-includes/getting-started-install/java.spring-boot.mdx +++ b/platform-includes/getting-started-install/java.spring-boot.mdx @@ -1,5 +1,5 @@ ```groovy {tabTitle:Gradle Plugin} From 818f64af2723d9e3eee3eab8e30d19f13d0a2920 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Mon, 1 Dec 2025 14:07:32 +0100 Subject: [PATCH 2/4] add logs option to servlet and spring --- .../getting-started-config/java.mdx | 7 +++ .../getting-started-config/java.servlet.mdx | 43 +++++++++++++++++++ .../java.spring-boot.mdx | 2 +- .../getting-started-config/java.spring.mdx | 9 +++- .../opentelemetry/java.mdx | 8 ++++ .../getting-started-install/java.servlet.mdx | 2 +- .../getting-started-install/java.spring.mdx | 2 +- 7 files changed, 68 insertions(+), 5 deletions(-) diff --git a/platform-includes/getting-started-config/java.mdx b/platform-includes/getting-started-config/java.mdx index c725f2f74a013b..3ab8bbd95cbeda 100644 --- a/platform-includes/getting-started-config/java.mdx +++ b/platform-includes/getting-started-config/java.mdx @@ -60,4 +60,11 @@ Sentry.init { options -> // ___PRODUCT_OPTION_END___ logs } ``` + + + +Learn more about setting up logging in our Logs documentation. + + + diff --git a/platform-includes/getting-started-config/java.servlet.mdx b/platform-includes/getting-started-config/java.servlet.mdx index bb32e8df3701e3..d881ae1dcc8e2b 100644 --- a/platform-includes/getting-started-config/java.servlet.mdx +++ b/platform-includes/getting-started-config/java.servlet.mdx @@ -22,6 +22,24 @@ public final class SentryInitializer implements ServletContainerInitializer { // Add data like request headers and IP for users, // see https://docs.sentry.io/platforms/java/guides/servlet/data-management/data-collected/ for more info options.setSendDefaultPii(true); + // ___PRODUCT_OPTION_START___ performance + + // Set traces_sample_rate to 1.0 to capture 100% + // of transactions for tracing. + // We recommend adjusting this value in production. + options.setTracesSampleRate(1.0); + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + // Enable profiling + options.setProfileSessionSampleRate(1.0); + options.setProfileLifecycle(ProfileLifecycle.TRACE); + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.getLogs().setEnabled(true); + // ___PRODUCT_OPTION_END___ logs }); } } @@ -43,10 +61,35 @@ class SentryInitializer : ServletContainerInitializer { // Add data like request headers and IP for users, // see https://docs.sentry.io/platforms/java/guides/servlet/data-management/data-collected/ for more info options.isSendDefaultPii = true + // ___PRODUCT_OPTION_START___ performance + + // Set traces_sample_rate to 1.0 to capture 100% + // of transactions for tracing. + // We recommend adjusting this value in production. + options.tracesSampleRate = 1.0 + // ___PRODUCT_OPTION_END___ performance + // ___PRODUCT_OPTION_START___ profiling + + // Enable profiling + options.profileSessionSampleRate = 1.0 + options.profileLifecycle = ProfileLifecycle.TRACE + // ___PRODUCT_OPTION_END___ profiling + // ___PRODUCT_OPTION_START___ logs + + // Enable logs to be sent to Sentry + options.logs.enabled = true + // ___PRODUCT_OPTION_END___ logs } } } ``` + + + +Learn more about setting up logging in our Logs documentation. + + + Create a file in `src/main/resources/META-INF/services` named `javax.servlet.ServletContainerInitializer`, with a full name of your custom `SentryInitializer` class as a content: diff --git a/platform-includes/getting-started-config/java.spring-boot.mdx b/platform-includes/getting-started-config/java.spring-boot.mdx index 555ee298f968db..bacb025bc1908a 100644 --- a/platform-includes/getting-started-config/java.spring-boot.mdx +++ b/platform-includes/getting-started-config/java.spring-boot.mdx @@ -25,7 +25,7 @@ sentry.profile-lifecycle=TRACE // ___PRODUCT_OPTION_START___ logs # Enable logs -sentry.logs.enabled: true +sentry.logs.enabled=true // ___PRODUCT_OPTION_END___ logs ``` diff --git a/platform-includes/getting-started-config/java.spring.mdx b/platform-includes/getting-started-config/java.spring.mdx index 12cef2c90b579b..fc437a87c88d2f 100644 --- a/platform-includes/getting-started-config/java.spring.mdx +++ b/platform-includes/getting-started-config/java.spring.mdx @@ -190,16 +190,21 @@ import org.springframework.core.Ordered class SentryConfiguration ``` - The SDK can be configured using a `sentry.properties` file: ```properties {filename:sentry.properties} +// ___PRODUCT_OPTION_START___ performance +# Enable tracing traces-sample-rate=1.0 +// ___PRODUCT_OPTION_END___ performance // ___PRODUCT_OPTION_START___ profiling # Enable profiling profile-session-sample-rate=1.0 profile-lifecycle=TRACE // ___PRODUCT_OPTION_END___ profiling +// ___PRODUCT_OPTION_START___ logs +# Enable logs +logs.enabled=true +// ___PRODUCT_OPTION_END___ logs ``` - diff --git a/platform-includes/getting-started-config/opentelemetry/java.mdx b/platform-includes/getting-started-config/opentelemetry/java.mdx index 7770dd5d258b48..a3d2c434bc21aa 100644 --- a/platform-includes/getting-started-config/opentelemetry/java.mdx +++ b/platform-includes/getting-started-config/opentelemetry/java.mdx @@ -20,4 +20,12 @@ profile-session-sample-rate=1.0 profile-lifecycle=TRACE // ___PRODUCT_OPTION_END___ profiling ``` + + + + +Learn more about setting up logging in our Logs documentation. + + + diff --git a/platform-includes/getting-started-install/java.servlet.mdx b/platform-includes/getting-started-install/java.servlet.mdx index 3e33f8234d0345..e214803352595d 100644 --- a/platform-includes/getting-started-install/java.servlet.mdx +++ b/platform-includes/getting-started-install/java.servlet.mdx @@ -1,5 +1,5 @@ ```xml {tabTitle:Maven} diff --git a/platform-includes/getting-started-install/java.spring.mdx b/platform-includes/getting-started-install/java.spring.mdx index 7f33d0f534e4c9..a5bb24a35b487c 100644 --- a/platform-includes/getting-started-install/java.spring.mdx +++ b/platform-includes/getting-started-install/java.spring.mdx @@ -1,5 +1,5 @@ ```groovy {tabTitle:Gradle Plugin} From b6c663c7d9848c58e89517446c0c7ca824b11ce6 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Mon, 1 Dec 2025 14:32:24 +0100 Subject: [PATCH 3/4] split logging-frameworks in spring boot into their own respective pages --- .../spring-boot/logging-frameworks/index.mdx | 11 ++ .../spring-boot/logging-frameworks/log4j2.mdx | 81 +++++++++++++ .../logback.mdx} | 108 +++++------------- platform-includes/logs/integrations/java.mdx | 3 +- 4 files changed, 122 insertions(+), 81 deletions(-) create mode 100644 docs/platforms/java/guides/spring-boot/logging-frameworks/index.mdx create mode 100644 docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx rename docs/platforms/java/guides/spring-boot/{logging-frameworks.mdx => logging-frameworks/logback.mdx} (50%) diff --git a/docs/platforms/java/guides/spring-boot/logging-frameworks/index.mdx b/docs/platforms/java/guides/spring-boot/logging-frameworks/index.mdx new file mode 100644 index 00000000000000..88d692b7c962b7 --- /dev/null +++ b/docs/platforms/java/guides/spring-boot/logging-frameworks/index.mdx @@ -0,0 +1,11 @@ +--- +title: Logging Framework Integrations +sidebar_order: 6 +description: "Learn more about using one of our logging integrations with Sentry Spring Boot." +--- + +## Supported Logging Frameworks + +Sentry provides integrations for the following logging frameworks with Spring Boot: + + diff --git a/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx b/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx new file mode 100644 index 00000000000000..746293f572de8b --- /dev/null +++ b/docs/platforms/java/guides/spring-boot/logging-frameworks/log4j2.mdx @@ -0,0 +1,81 @@ +--- +title: Log4j 2 Integration +description: "Learn how to use Sentry's Log4j 2 integration with Spring Boot." +--- + +For the best experience, we recommend using Sentry's Spring Boot integration with the Log4j 2 logging framework integration as they work together seamlessly. + + + +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 `minimumLevel` are automatically sent as Sentry Logs when enabled. + + + +## Installation + +To use Sentry's Log4j 2 integration in Spring Boot application, you must include a dependency to the `sentry-log4j2` module: + +```xml {tabTitle:Maven} + + io.sentry + sentry-log4j2 + {{@inject packages.version('sentry.java.log4j2', '5.1.1') }} + +``` + +```groovy {tabTitle:Gradle} +implementation 'io.sentry:sentry-log4j2:{{@inject packages.version('sentry.java.log4j2', '5.1.1') }}' +``` + +```scala {tabTitle: SBT} +libraryDependencies += "io.sentry" % "sentry-log4j2" % "{{@inject packages.version('sentry.java.log4j2', '5.1.1') }}" +``` + +For other dependency managers see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-log4j2). + +## Configuration + +### 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 +``` + +### XML Configuration + +[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 + + + + + + + + + + + + + + + + + + +``` + + + +You do not need to configure your DSN in the Log4j 2 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 Log4j 2 and Spring Boot configurations. + + + +## Mapped Diagnostic Context (MDC) + +Starting with Sentry Java SDK version 8.24.0, you can use the `contextTags` option to include specific properties from the Mapped Diagnostic Context (MDC) as attributes on log entries sent to Sentry. diff --git a/docs/platforms/java/guides/spring-boot/logging-frameworks.mdx b/docs/platforms/java/guides/spring-boot/logging-frameworks/logback.mdx similarity index 50% rename from docs/platforms/java/guides/spring-boot/logging-frameworks.mdx rename to docs/platforms/java/guides/spring-boot/logging-frameworks/logback.mdx index e1765d5c7a93fc..7268412a89fed3 100644 --- a/docs/platforms/java/guides/spring-boot/logging-frameworks.mdx +++ b/docs/platforms/java/guides/spring-boot/logging-frameworks/logback.mdx @@ -1,18 +1,35 @@ --- -title: Logging Framework Integrations -sidebar_order: 6 -description: "Learn more about using one of our logging integrations with Sentry Spring Boot." +title: Logback Integration +description: "Learn how to use Sentry's Logback integration with Spring Boot." --- -For the best experience, we recommend using Sentry's Spring Boot integration with one of the logging framework integrations as they work together seamlessly. +For the best experience, we recommend using Sentry's Spring Boot integration with the Logback logging framework integration as they work together seamlessly. -By default these integrations capture 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. +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. -## Spring Boot Configuration +## 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 {tabTitle:Maven} + + io.sentry + sentry-logback + {{@inject packages.version('sentry.java.logback', '4.2.0') }} + +``` + +```groovy {tabTitle:Gradle} +implementation 'io.sentry:sentry-logback:{{@inject packages.version('sentry.java.logback', '4.2.0') }}' +``` + +## Configuration + +### Spring Boot Configuration To send logs to Sentry and have them show up in the Logs section, you need to enable the feature: @@ -40,21 +57,7 @@ When `SentryAppender` auto-configuration does not suit your needs, it can be tur sentry.logging.enabled=false ``` -### Logback - -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 {tabTitle:Maven} - - io.sentry - sentry-logback - {{@inject packages.version('sentry.java.logback', '4.2.0') }} - -``` - -```groovy {tabTitle:Gradle} -implementation 'io.sentry:sentry-logback:{{@inject packages.version('sentry.java.logback', '4.2.0') }}' -``` +### 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: @@ -64,7 +67,9 @@ If you decide to opt-out from the `application.properties` based Spring Boot log - + + INFO + @@ -81,63 +86,6 @@ However, if errors that may appear during startup should to be sent to Sentry, t -#### Mapped Diagnostic Context (MDC) - -Starting with Sentry Java SDK version 8.24.0, you can use the `contextTags` option to include specific properties from the Mapped Diagnostic Context (MDC) as attributes on log entries sent to Sentry. - -### Log4j 2 - -To use Sentry's Log4j 2 integration in Spring Boot application, you must include a dependency to the `sentry-log4j2` module: - -```xml {tabTitle:Maven} - - io.sentry - sentry-log4j2 - {{@inject packages.version('sentry.java.log4j2', '5.1.1') }} - -``` - -```groovy {tabTitle:Gradle} -implementation 'io.sentry:sentry-log4j2:{{@inject packages.version('sentry.java.log4j2', '5.1.1') }}' -``` - -```scala {tabTitle: SBT} -libraryDependencies += "io.sentry" % "sentry-log4j2" % "{{@inject packages.version('sentry.java.log4j2', '5.1.1') }}" -``` - -For other dependency managers see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-log4j2). - -Then [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 - - - - - - - - - - - - - - - - - - -``` - - - -You do not need to configure your DSN in the Log4j 2 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 Log4j 2 and Spring Boot configurations. - - - -#### Mapped Diagnostic Context (MDC) +## Mapped Diagnostic Context (MDC) Starting with Sentry Java SDK version 8.24.0, you can use the `contextTags` option to include specific properties from the Mapped Diagnostic Context (MDC) as attributes on log entries sent to Sentry. diff --git a/platform-includes/logs/integrations/java.mdx b/platform-includes/logs/integrations/java.mdx index 06b2d5741ba885..de308b84eaee96 100644 --- a/platform-includes/logs/integrations/java.mdx +++ b/platform-includes/logs/integrations/java.mdx @@ -1,5 +1,6 @@ Available integrations: -- [Spring Boot using Logback](/platforms/java/guides/spring-boot/logging-frameworks/) +- [Spring Boot using Logback](/platforms/java/guides/spring-boot/logging-frameworks/logback) +- [Spring Boot using Log4j2](/platforms/java/guides/spring-boot/logging-frameworks/log4j2) - [Logback](/platforms/java/guides/logback/logs/) - [Log4j2](/platforms/java/guides/log4j2/logs/) - [JUL](/platforms/java/guides/jul/logs/) From abfa568f024a876dd094ed0591776d8b03bd40a0 Mon Sep 17 00:00:00 2001 From: Lukas Bloder Date: Tue, 2 Dec 2025 09:36:43 +0100 Subject: [PATCH 4/4] add cta header to log integrations, add logs option to jul --- platform-includes/getting-started-config/java.jul.mdx | 7 +++++++ platform-includes/getting-started-install/java.jul.mdx | 2 +- platform-includes/getting-started-primer/java.jul.mdx | 6 ++++++ platform-includes/getting-started-primer/java.log4j2.mdx | 6 ++++++ platform-includes/getting-started-primer/java.logback.mdx | 6 ++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/platform-includes/getting-started-config/java.jul.mdx b/platform-includes/getting-started-config/java.jul.mdx index 0a523ab7b22d23..40bdc1d56e638f 100644 --- a/platform-includes/getting-started-config/java.jul.mdx +++ b/platform-includes/getting-started-config/java.jul.mdx @@ -38,6 +38,10 @@ dsn=___PUBLIC_DSN___ # Add data like request headers and IP for users, # see https://docs.sentry.io/platforms/java/guides/jul/data-management/data-collected/ for more info send-default-pii=true + +# Enable logs +logs.enabled=true + ``` @@ -47,6 +51,9 @@ Two log levels are used to configure this integration: 1. Configure the lowest level required for a log message to become an event (`minimumEventLevel`) sent to Sentry. 2. Configure the lowest level a message has to be to become a breadcrumb (`minimumBreadcrumbLevel`). + +3. Configure the lowest level a message has to be to be sent as Sentry Log (`minimumLevel`). + diff --git a/platform-includes/getting-started-install/java.jul.mdx b/platform-includes/getting-started-install/java.jul.mdx index 86761ceec1eb6b..e91230044175e9 100644 --- a/platform-includes/getting-started-install/java.jul.mdx +++ b/platform-includes/getting-started-install/java.jul.mdx @@ -1,5 +1,5 @@ ```xml {tabTitle:Maven} diff --git a/platform-includes/getting-started-primer/java.jul.mdx b/platform-includes/getting-started-primer/java.jul.mdx index 6d4c29d67e15fc..91a706a0ef571d 100644 --- a/platform-includes/getting-started-primer/java.jul.mdx +++ b/platform-includes/getting-started-primer/java.jul.mdx @@ -4,4 +4,10 @@ The `sentry-jul` library provides a [java.util.logging Handler](http://docs.orac + + + Enable the Sentry Logs feature to unlock Sentry's full logging power. With Sentry Logs, you can search, filter, and analyze logs from across your entire application in one place. + + + Once this integration is configured you can _also_ use Sentry’s static API, as shown on the usage page, in order to do things like record breadcrumbs, set the current user, or manually send events. The source can be found [on GitHub](https://github.com/getsentry/sentry-java/tree/master/sentry-jul). diff --git a/platform-includes/getting-started-primer/java.log4j2.mdx b/platform-includes/getting-started-primer/java.log4j2.mdx index 8d6dd2f15f689f..fe7c90d61d5213 100644 --- a/platform-includes/getting-started-primer/java.log4j2.mdx +++ b/platform-includes/getting-started-primer/java.log4j2.mdx @@ -4,4 +4,10 @@ The `sentry-log4j2` library provides [Log4j 2.x](https://logging.apache.org/log4 + + + Enable the Sentry Logs feature to unlock Sentry's full logging power. With Sentry Logs, you can search, filter, and analyze logs from across your entire application in one place. + + + Once the integration is configured you can _also_ use Sentry’s static API, [as shown on the usage page](usage/), in order to do things like record breadcrumbs, set the current user, or manually send events. The source can be found [on GitHub](https://github.com/getsentry/sentry-java/tree/master/sentry-log4j2). diff --git a/platform-includes/getting-started-primer/java.logback.mdx b/platform-includes/getting-started-primer/java.logback.mdx index 1b6508c1b726cc..63d27a958be47a 100644 --- a/platform-includes/getting-started-primer/java.logback.mdx +++ b/platform-includes/getting-started-primer/java.logback.mdx @@ -4,4 +4,10 @@ The `sentry-logback` library provides [Logback](https://logback.qos.ch/) support + + + Enable the Sentry Logs feature to unlock Sentry's full logging power. With Sentry Logs, you can search, filter, and analyze logs from across your entire application in one place. + + + Once this integration is configured you can _also_ use Sentry’s static API, [as shown on the usage page](usage/), in order to do things like record breadcrumbs, set the current user, or manually send events. The source can be found [on GitHub](https://github.com/getsentry/sentry-java/tree/master/sentry-logback).