Skip to content

Commit 8173e57

Browse files
authored
feat(java): Document contextTags for logs (#15245)
1 parent dbd7fd8 commit 8173e57

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

docs/platforms/java/guides/jul/usage/advanced-usage.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,11 @@ class MyClass {
158158

159159
## Context Tags
160160

161-
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.
161+
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`.
162162

163+
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.".
164+
165+
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.
163166

164167
```properties {tabTitle:Properties}
165168
dsn=___PUBLIC_DSN___

docs/platforms/java/guides/log4j2/advanced_usage.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,11 @@ class MyClass {
141141

142142
## Context Tags
143143

144-
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 `<Sentry>` tag in your `log4j2.xml` with the tags as comma-separated items.
144+
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`.
145145

146+
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.".
147+
148+
To define a tag that shall be sent with events and logs, add a `contextTags` attribute to the `<Sentry>` tag in your `log4j2.xml` with the tags as comma-separated items.
146149

147150
```xml {tabTitle:XML}
148151
<Sentry name="Sentry"

docs/platforms/java/guides/logback/usage/advanced-usage.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,11 @@ class MyClass {
140140

141141
## Context Tags
142142

143-
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 a tag, add a `<contextTag>` entry inside the `<options>` of the Sentry appender configuration in `logback.xml`
143+
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`.
144144

145+
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.".
146+
147+
To define a tag that shall be sent with events and logs, add a `<contextTag>` entry inside the `<options>` of the Sentry appender configuration in `logback.xml`.
145148

146149
```xml {tabTitle:XML}
147150
<appender name="sentry" class="io.sentry.logback.SentryAppender">

docs/platforms/java/guides/spring-boot/logging-frameworks.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ However, if errors that may appear during startup should to be sent to Sentry, t
7373

7474
</Alert>
7575

76+
#### Mapped Diagnostic Context (MDC)
77+
78+
Starting with Sentry Java SDK version 8.24.0, you can use the <PlatformLink to="/configuration/options/#contextTags">`contextTags`</PlatformLink> option to include specific properties from the Mapped Diagnostic Context (MDC) as attributes on log entries sent to Sentry.
79+
7680
### Log4j 2
7781

7882
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
125129
However, if errors that may appear during startup should to be sent to Sentry, the DSN must be provided to <i>both</i> the Log4j 2 and Spring Boot configurations.
126130

127131
</Alert>
132+
133+
#### Mapped Diagnostic Context (MDC)
134+
135+
Starting with Sentry Java SDK version 8.24.0, you can use the <PlatformLink to="/configuration/options/#contextTags">`contextTags`</PlatformLink> option to include specific properties from the Mapped Diagnostic Context (MDC) as attributes on log entries sent to Sentry.

platform-includes/logs/options/java.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ Sentry.init { options ->
3131

3232

3333
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.
34+
35+
#### contextTags
36+
37+
You can use the <PlatformLink to="/configuration/options/#contextTags">`contextTags`</PlatformLink> option to include specific properties from the Mapped Diagnostic Context (MDC) as attributes on log entries sent to Sentry.
38+
39+
For detailed configuration examples, see the Advanced Usage documentation for your logging framework.

0 commit comments

Comments
 (0)