You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: "Learn how to use Sentry's Log4j 2 integration with Spring Boot."
4
+
---
5
+
6
+
For the best experience, we recommend using Sentry's Spring Boot integration with the Log4j 2 logging framework integration as they work together seamlessly.
7
+
8
+
<Alertlevel="warning"title="Logs over Breadcrumbs">
9
+
10
+
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.
11
+
12
+
</Alert>
13
+
14
+
## Installation
15
+
16
+
To use Sentry's Log4j 2 integration in Spring Boot application, you must include a dependency to the `sentry-log4j2` module:
For other dependency managers see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-log4j2).
35
+
36
+
## Configuration
37
+
38
+
### Spring Boot Configuration
39
+
40
+
To send logs to Sentry and have them show up in the Logs section, you need to enable the feature:
41
+
42
+
```properties
43
+
sentry.logs.enabled=true
44
+
```
45
+
46
+
### XML Configuration
47
+
48
+
[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:
You do not need to configure your DSN in the Log4j 2 configuration file since Sentry is configured from the Spring Boot integration.
74
+
75
+
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.
76
+
77
+
</Alert>
78
+
79
+
## Mapped Diagnostic Context (MDC)
80
+
81
+
Starting with Sentry Java SDK version 8.24.0, you can use the <PlatformLinkto="/configuration/options/#contextTags">`contextTags`</PlatformLink> option to include specific properties from the Mapped Diagnostic Context (MDC) as attributes on log entries sent to Sentry.
description: "Learn more about using one of our logging integrations with Sentry Spring Boot."
2
+
title: Logback Integration
3
+
description: "Learn how to use Sentry's Logback integration with Spring Boot."
5
4
---
6
5
7
-
For the best experience, we recommend using Sentry's Spring Boot integration with one of the logging framework integrations as they work together seamlessly.
6
+
For the best experience, we recommend using Sentry's Spring Boot integration with the Logback logging framework integration as they work together seamlessly.
8
7
9
-
### Logback
8
+
<Alertlevel="warning"title="Logs over Breadcrumbs">
9
+
10
+
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.
11
+
12
+
</Alert>
13
+
14
+
## Installation
10
15
11
16
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`:
12
17
@@ -22,6 +27,16 @@ To use Sentry Logback integration in Spring Boot application you must include a
To send logs to Sentry and have them show up in the Logs section, you need to enable the feature:
35
+
36
+
```properties
37
+
sentry.logs.enabled=true
38
+
```
39
+
25
40
Minimum logging levels for `SentryAppender` can be configured in `application.properties` or `application.yml` file.
26
41
27
42
```properties
@@ -36,18 +51,14 @@ The default values are:
36
51
-`info` or higher will send a log message to Sentry and will show up in the Logs section.
37
52
-`error` or higher will send an event to Sentry and will show up in the Issues section.
38
53
39
-
To send logs to Sentry and have them show up in the Logs section, you need to enable the feature:
40
-
41
-
```properties
42
-
sentry.logs.enabled=true
43
-
```
44
-
45
54
When `SentryAppender` auto-configuration does not suit your needs, it can be turned off by setting:
46
55
47
56
```properties
48
57
sentry.logging.enabled=false
49
58
```
50
59
60
+
### XML Configuration
61
+
51
62
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:
52
63
53
64
```xml
@@ -56,7 +67,9 @@ If you decide to opt-out from the `application.properties` based Spring Boot log
@@ -73,63 +86,6 @@ However, if errors that may appear during startup should to be sent to Sentry, t
73
86
74
87
</Alert>
75
88
76
-
#### Mapped Diagnostic Context (MDC)
77
-
78
-
Starting with Sentry Java SDK version 8.24.0, you can use the <PlatformLinkto="/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
-
80
-
### Log4j 2
81
-
82
-
To use Sentry's Log4j 2 integration in Spring Boot application, you must include a dependency to the `sentry-log4j2` module:
For other dependency managers see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-log4j2).
101
-
102
-
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:
You do not need to configure your DSN in the Log4j 2 configuration file since Sentry is configured from the Spring Boot integration.
128
-
129
-
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.
130
-
131
-
</Alert>
132
-
133
-
#### Mapped Diagnostic Context (MDC)
89
+
## Mapped Diagnostic Context (MDC)
134
90
135
91
Starting with Sentry Java SDK version 8.24.0, you can use the <PlatformLinkto="/configuration/options/#contextTags">`contextTags`</PlatformLink> option to include specific properties from the Mapped Diagnostic Context (MDC) as attributes on log entries sent to Sentry.
Copy file name to clipboardExpand all lines: platform-includes/getting-started-config/java.logback.mdx
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,11 @@ The `ConsoleAppender` is provided only as an example of a non-Sentry appender se
25
25
<dsn>___PUBLIC_DSN___</dsn>
26
26
<!-- Add data like request headers and IP for users, see https://docs.sentry.io/platforms/java/guides/logback/data-management/data-collected/ for more info -->
27
27
<sendDefaultPii>true</sendDefaultPii>
28
+
// ___PRODUCT_OPTION_START___ logs
29
+
<logs>
30
+
<enabled>true</enabled>
31
+
</logs>
32
+
// ___PRODUCT_OPTION_END___ logs
28
33
</options>
29
34
</appender>
30
35
@@ -87,6 +92,9 @@ Two log levels are used to configure this integration:
87
92
88
93
1. Configure the lowest level required for a log message to become an event (`minimumEventLevel`) sent to Sentry.
89
94
2. Configure the lowest level a message has to be to become a breadcrumb (`minimumBreadcrumbLevel`).
95
+
<OnboardingOptionoptionId="logs">
96
+
3. Configure the lowest level a message has to be to be sent as Sentry Log (`minimumLevel`).
97
+
</OnboardingOption>
90
98
91
99
<Alert>
92
100
@@ -110,6 +118,10 @@ Breadcrumbs are kept in memory (by default the last 100 records) and are sent wi
110
118
<minimumEventLevel>WARN</minimumEventLevel>
111
119
<!-- Optionally change minimum Breadcrumbs level. Default for Breadcrumbs is INFO -->
0 commit comments