From c9334f620c608a11211229e7dbd97cf6c2809034 Mon Sep 17 00:00:00 2001 From: lcian <17258265+lcian@users.noreply.github.com> Date: Thu, 16 Oct 2025 11:52:48 +0200 Subject: [PATCH 1/4] feat(java): Document contextTags for logs --- docs/platforms/java/guides/jul/usage/advanced-usage.mdx | 3 ++- docs/platforms/java/guides/log4j2/advanced_usage.mdx | 3 ++- .../java/guides/logback/usage/advanced-usage.mdx | 3 ++- .../java/guides/spring-boot/logging-frameworks.mdx | 8 ++++++++ platform-includes/logs/options/java.mdx | 6 ++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/docs/platforms/java/guides/jul/usage/advanced-usage.mdx b/docs/platforms/java/guides/jul/usage/advanced-usage.mdx index 51c129b1ef24a..6509bec51f29e 100644 --- a/docs/platforms/java/guides/jul/usage/advanced-usage.mdx +++ b/docs/platforms/java/guides/jul/usage/advanced-usage.mdx @@ -158,8 +158,9 @@ class MyClass { ## Context Tags -Starting with Sentry version 6.0.0 and up, you can define a list of `MDC tags` that will be viewable as `Tags` in the Sentry UI. `MDC Tags` not in this list will be viewable as `Context Data`. To define tags, add a `context-tags` entry with the tags as comma-separated items to the `sentry.properties` file. +Starting with Sentry version 6.0.0 and up, you can define a list of `MDC tags` that will be viewable as `Tags` in the Sentry UI. `MDC Tags` not in this list will be viewable as `Context Data`. +As of Sentry Java SDK version 8.24.0, `contextTags` also applies to [structured logs](https://docs.sentry.io/product/explore/logs/). MDC properties matching the configured `contextTags` will be attached to log entries as attributes, prefixed with "mdc.". ```properties {tabTitle:Properties} dsn=___PUBLIC_DSN___ diff --git a/docs/platforms/java/guides/log4j2/advanced_usage.mdx b/docs/platforms/java/guides/log4j2/advanced_usage.mdx index 4a642de1bf5e7..8e90c915d7ddf 100644 --- a/docs/platforms/java/guides/log4j2/advanced_usage.mdx +++ b/docs/platforms/java/guides/log4j2/advanced_usage.mdx @@ -141,8 +141,9 @@ class MyClass { ## Context Tags -Starting with Sentry version 6.0.0 and up, you can define a list of `MDC tags` that will be viewable as `Tags` in the Sentry UI. `MDC Tags` not in this list will be viewable as `Context Data`. To define tags, add a `contextTags` attribute to the `` tag in your `log4j2.xml` with the tags as comma-separated items. +Starting with Sentry version 6.0.0 and up, you can define a list of `MDC tags` that will be viewable as `Tags` in the Sentry UI. `MDC Tags` not in this list will be viewable as `Context Data`. +As of Sentry Java SDK version 8.24.0, `contextTags` also applies to [structured logs](https://docs.sentry.io/product/explore/logs/). MDC properties matching the configured `contextTags` will be attached to log entries as attributes, prefixed with "mdc.". ```xml {tabTitle:XML} ` entry inside the `` of the Sentry appender configuration in `logback.xml` +Starting with Sentry version 6.0.0 and up, you can define a list of `MDC tags` that will be viewable as `Tags` in the Sentry UI. `MDC Tags` not in this list will be viewable as `Context Data`. +As of Sentry Java SDK version 8.24.0, `contextTags` also applies to [structured logs](https://docs.sentry.io/product/explore/logs/). MDC properties matching the configured `contextTags` will be attached to log entries as attributes, prefixed with "mdc.". ```xml {tabTitle:XML} diff --git a/docs/platforms/java/guides/spring-boot/logging-frameworks.mdx b/docs/platforms/java/guides/spring-boot/logging-frameworks.mdx index d4128fe3ada9b..5fc7aaee7f499 100644 --- a/docs/platforms/java/guides/spring-boot/logging-frameworks.mdx +++ b/docs/platforms/java/guides/spring-boot/logging-frameworks.mdx @@ -73,6 +73,10 @@ 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: @@ -125,3 +129,7 @@ You do not need to configure your DSN in the Log4j 2 configuration file since Se 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/platform-includes/logs/options/java.mdx b/platform-includes/logs/options/java.mdx index 7c6a6d8c1b916..3809d877f6568 100644 --- a/platform-includes/logs/options/java.mdx +++ b/platform-includes/logs/options/java.mdx @@ -31,3 +31,9 @@ Sentry.init { options -> The `beforeSend` function receives a log object, and should return the log object if you want it to be sent to Sentry, or `null` if you want to discard it. + +#### contextTags + +You can use the `contextTags` option to include specific properties from the Mapped Diagnostic Context (MDC) as attributes on log entries sent to Sentry. + +For detailed configuration examples, see the Advanced Usage documentation for your logging framework. From 6c622a461980f8fdae0187b9a222d5b95ab11234 Mon Sep 17 00:00:00 2001 From: Lorenzo Cian <17258265+lcian@users.noreply.github.com> Date: Tue, 21 Oct 2025 13:37:32 +0200 Subject: [PATCH 2/4] Update advanced-usage.mdx --- docs/platforms/java/guides/logback/usage/advanced-usage.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/platforms/java/guides/logback/usage/advanced-usage.mdx b/docs/platforms/java/guides/logback/usage/advanced-usage.mdx index b6bb97b7b4bea..c643ce4450e57 100644 --- a/docs/platforms/java/guides/logback/usage/advanced-usage.mdx +++ b/docs/platforms/java/guides/logback/usage/advanced-usage.mdx @@ -144,6 +144,8 @@ Starting with Sentry version 6.0.0 and up, you can define a list of `MDC tags` t As of Sentry Java SDK version 8.24.0, `contextTags` also applies to [structured logs](https://docs.sentry.io/product/explore/logs/). MDC properties matching the configured `contextTags` will be attached to log entries as attributes, prefixed with "mdc.". +To define a tag that shall be sent with events and logs, add a `` entry inside the `` of the Sentry appender configuration in `logback.xml`. + ```xml {tabTitle:XML} From 6c3dd2eb260eceb1cb10b916123e57d3ddfc5269 Mon Sep 17 00:00:00 2001 From: Lorenzo Cian <17258265+lcian@users.noreply.github.com> Date: Tue, 21 Oct 2025 13:38:32 +0200 Subject: [PATCH 3/4] Update advanced_usage.mdx --- docs/platforms/java/guides/log4j2/advanced_usage.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/platforms/java/guides/log4j2/advanced_usage.mdx b/docs/platforms/java/guides/log4j2/advanced_usage.mdx index 8e90c915d7ddf..f250d2e74aa33 100644 --- a/docs/platforms/java/guides/log4j2/advanced_usage.mdx +++ b/docs/platforms/java/guides/log4j2/advanced_usage.mdx @@ -145,6 +145,8 @@ Starting with Sentry version 6.0.0 and up, you can define a list of `MDC tags` t As of Sentry Java SDK version 8.24.0, `contextTags` also applies to [structured logs](https://docs.sentry.io/product/explore/logs/). MDC properties matching the configured `contextTags` will be attached to log entries as attributes, prefixed with "mdc.". +To define a tag that shall be sent with events and logs, add a `contextTags` attribute to the `` tag in your `log4j2.xml` with the tags as comma-separated items. + ```xml {tabTitle:XML} Date: Tue, 21 Oct 2025 13:39:11 +0200 Subject: [PATCH 4/4] Add context-tags configuration for Sentry Added instructions for defining context-tags in sentry.properties. --- docs/platforms/java/guides/jul/usage/advanced-usage.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/platforms/java/guides/jul/usage/advanced-usage.mdx b/docs/platforms/java/guides/jul/usage/advanced-usage.mdx index 6509bec51f29e..59265c46e9936 100644 --- a/docs/platforms/java/guides/jul/usage/advanced-usage.mdx +++ b/docs/platforms/java/guides/jul/usage/advanced-usage.mdx @@ -162,6 +162,8 @@ Starting with Sentry version 6.0.0 and up, you can define a list of `MDC tags` t As of Sentry Java SDK version 8.24.0, `contextTags` also applies to [structured logs](https://docs.sentry.io/product/explore/logs/). MDC properties matching the configured `contextTags` will be attached to log entries as attributes, prefixed with "mdc.". +To define a tag that shall be sent with events and logs, add a `context-tags` entry with the tags as comma-separated items to the `sentry.properties` file. + ```properties {tabTitle:Properties} dsn=___PUBLIC_DSN___ context-tags=userId,requestId