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
* Fix Log4j configurations and improve wording
* Remove Log4j schema
Co-authored-by: Piotr P. Karwasz <[email protected]>
* Remove Log4j schema
Co-authored-by: Piotr P. Karwasz <[email protected]>
* Remove Log4j schema
Co-authored-by: Piotr P. Karwasz <[email protected]>
* Apply suggestions from code review
---------
Co-authored-by: Piotr P. Karwasz <[email protected]>
Co-authored-by: Alexander Dinauer <[email protected]>
Co-authored-by: Alexander Dinauer <[email protected]>
Copy file name to clipboardExpand all lines: docs/platforms/java/common/legacy/log4j2/index.mdx
+19-18
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ An [updated Java SDK](/platforms/java/) SDK supersedes this deprecated version.
9
9
10
10
</Alert>
11
11
12
-
The `sentry-log4j2` library provides [Log4j 2.x](https://logging.apache.org/log4j/2.x/) support for Sentry via an [Appender](https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/Appender.html) that sends logged exceptions to Sentry. Once this integration is configured you can _also_ use Sentry’s static API, [as shown on the usage page](/platforms/java/legacy/usage), in order to do things like record breadcrumbs, set the current user, or manually send events.
12
+
The `sentry-log4j2` library provides [Log4j 2](https://logging.apache.org/log4j/2.x/) support for Sentry via an [Appender](https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/Appender.html) that sends logged exceptions to Sentry. Once this integration is configured you can _also_ use Sentry’s static API, [as shown on the usage page](/platforms/java/legacy/usage), in order to do things like record breadcrumbs, set the current user, or manually send events.
13
13
14
14
The source can be found [on GitHub](https://github.com/getsentry/sentry-java/tree/master/sentry-log4j2).
15
15
@@ -41,23 +41,24 @@ Example configuration using the `log4j2.xml` format:
<!-- Note that the Sentry logging threshold is overridden to the WARN level -->
57
+
<AppenderRefref="SENTRY"level="WARN"/>
58
+
</Root>
59
+
</Loggers>
60
+
61
+
</Configuration>
61
62
```
62
63
63
64
Next, **you’ll need to configure your DSN** (client key) and optionally other values such as `environment` and `release`. [See the configuration page](/platforms/java/legacy/configuration/#setting-the-dsn) for ways you can do this.
For other dependency managers see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-log4j2).
89
89
90
-
Then [follow the guide on configuring Log4j2 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:
90
+
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 Log4j2 configuration file since Sentry is configured from the Spring Boot integration.
115
+
You do not need to configure your DSN in the Log4j 2 configuration file since Sentry is configured from the Spring Boot integration.
113
116
114
-
However, if errors that may appear during startup should to be sent to Sentry, the DSN must be provided to <i>both</i> the Log4j2 and Spring Boot configurations.
117
+
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.
When used together with one of the logging framework integrations, the Java SDK captures all error logs as events. If you see a particular kind of error very often that has a `logger` tag, you can ignore that particular logger entirely. For more information see our <Linkto="/platforms/java/guides/logback/">Logback</Link> or <Linkto="/platforms/java/guides/log4j2/">Log4j 2.x</Link> integration.
1
+
When used together with one of the logging framework integrations, the Java SDK captures all error logs as events. If you see a particular kind of error very often that has a `logger` tag, you can ignore that particular logger entirely. For more information see our <Linkto="/platforms/java/guides/logback/">Logback</Link> or <Linkto="/platforms/java/guides/log4j2/">Log4j 2</Link> integration.
`SentryAppender` does not support Log4j2's [async mode](https://logging.apache.org/log4j/2.x/manual/async.html). The Sentry Java SDK itself is already asynchronous and does not perform any blocking operation on the calling thread.
30
+
`SentryAppender` does not support [Log4j's asynchronous loggers](https://logging.apache.org/log4j/2.x/manual/async.html). The Sentry Java SDK itself is already asynchronous and does not perform any blocking operation on the calling thread.
30
31
31
32
### DSN Configuration
32
33
33
-
Note that **you need to configure your DSN** (client key) only if you wish to initialize the SDK through the log4j2 integration. If you're planning to use `Sentry.init` to provide configuration, such as by using the `beforeSend` callback, you **should not** provide the DSN in both `Sentry.init` and the appender configuration; just leave it out of the appender configuration in this case.
34
-
34
+
Note that **you need to configure your DSN** (client key) only if you wish to initialize the SDK through the Log4j 2 integration. If you're planning to use `Sentry.init` to provide configuration, such as by using the `beforeSend` callback, you **should not** provide the DSN in both `Sentry.init` and the appender configuration; just leave it out of the appender configuration in this case.
35
35
36
36
```xml
37
-
<Sentryname="Sentry"
38
-
dsn="___PUBLIC_DSN___" />
37
+
<Sentryname="SENTRY"dsn="___PUBLIC_DSN___" />
39
38
```
40
39
41
40
If the DSN is not present in the `log4j2.xml` configuration, Sentry will attempt to read it from the system property `sentry.dsn`, environment variable `SENTRY_DSN` or the `dsn` property in `sentry.properties` file. [See the configuration page](/platforms/java/configuration/) for more details on external configuration.
@@ -59,9 +58,8 @@ Breadcrumbs are kept in memory (by default the last 100 records) and are sent wi
59
58
```xml
60
59
<!-- Setting minimumBreadcrumbLevel modifies the default minimum level to add breadcrumbs from INFO to DEBUG -->
61
60
<!-- Setting minimumEventLevel the default minimum level to capture an event from ERROR to WARN -->
0 commit comments