-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Log4j configurations and wording #11395
Open
vy
wants to merge
1
commit into
getsentry:master
Choose a base branch
from
vy:log4j2-fixes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -65,9 +65,9 @@ However, if errors that may appear during startup should to be sent to Sentry, t | |||||||||
|
||||||||||
</Note> | ||||||||||
|
||||||||||
### Log4j2 | ||||||||||
### Log4j 2 | ||||||||||
|
||||||||||
To use Sentry's Log4j2 integration in Spring Boot application, you must include a dependency to the `sentry-log4j2` module: | ||||||||||
To use Sentry's Log4j 2 integration in Spring Boot application, you must include a dependency to the `sentry-log4j2` module: | ||||||||||
|
||||||||||
```xml {tabTitle:Maven} | ||||||||||
<dependency> | ||||||||||
|
@@ -87,30 +87,35 @@ libraryDependencies += "io.sentry" % "sentry-log4j2" % "{{@inject packages.versi | |||||||||
|
||||||||||
For other dependency managers see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-log4j2). | ||||||||||
|
||||||||||
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: | ||||||||||
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 | ||||||||||
<?xml version="1.0" encoding="UTF-8"?> | ||||||||||
<Configuration status="warn" packages="org.apache.logging.log4j.core,io.sentry.log4j2"> | ||||||||||
<Appenders> | ||||||||||
<Console name="Console" target="SYSTEM_OUT"> | ||||||||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> | ||||||||||
</Console> | ||||||||||
<Sentry name="Sentry" /> | ||||||||||
</Appenders> | ||||||||||
<Loggers> | ||||||||||
<Root level="info"> | ||||||||||
<AppenderRef ref="Sentry"/> | ||||||||||
<AppenderRef ref="Console"/> | ||||||||||
</Root> | ||||||||||
</Loggers> | ||||||||||
<Configuration xmlns="https://logging.apache.org/xml/ns" | ||||||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||||||
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-config-2.xsd"> | ||||||||||
Comment on lines
+94
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
<Appenders> | ||||||||||
<Console name="CONSOLE" target="SYSTEM_OUT"> | ||||||||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> | ||||||||||
</Console> | ||||||||||
<Sentry name="SENTRY"/> | ||||||||||
</Appenders> | ||||||||||
|
||||||||||
<Loggers> | ||||||||||
<Root level="INFO"> | ||||||||||
<AppenderRef ref="CONSOLE"/> | ||||||||||
<AppenderRef ref="SENTRY"/> | ||||||||||
</Root> | ||||||||||
</Loggers> | ||||||||||
|
||||||||||
</Configuration> | ||||||||||
``` | ||||||||||
|
||||||||||
<Note> | ||||||||||
|
||||||||||
You do not need to configure your DSN in the Log4j2 configuration file since Sentry is configured from the Spring Boot integration. | ||||||||||
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 <i>both</i> the Log4j2 and Spring Boot configurations. | ||||||||||
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. | ||||||||||
|
||||||||||
</Note> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +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 <Link to="/platforms/java/guides/logback/">Logback</Link> or <Link to="/platforms/java/guides/log4j2/">Log4j 2.x</Link> integration. | ||
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 <Link to="/platforms/java/guides/logback/">Logback</Link> or <Link to="/platforms/java/guides/log4j2/">Log4j 2</Link> integration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,36 +6,37 @@ The `ConsoleAppender` is provided only as an example of a non-Sentry appender se | |||||||||
|
||||||||||
</Note> | ||||||||||
|
||||||||||
|
||||||||||
```xml | ||||||||||
<?xml version="1.0" encoding="UTF-8"?> | ||||||||||
<Configuration status="warn" packages="org.apache.logging.log4j.core,io.sentry.log4j2"> | ||||||||||
<Appenders> | ||||||||||
<Console name="Console" target="SYSTEM_OUT"> | ||||||||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> | ||||||||||
</Console> | ||||||||||
<Sentry name="Sentry" | ||||||||||
dsn="___PUBLIC_DSN___" /> | ||||||||||
</Appenders> | ||||||||||
<Loggers> | ||||||||||
<Root level="info"> | ||||||||||
<AppenderRef ref="Sentry"/> | ||||||||||
<AppenderRef ref="Console"/> | ||||||||||
</Root> | ||||||||||
</Loggers> | ||||||||||
<Configuration xmlns="https://logging.apache.org/xml/ns" | ||||||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||||||
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-config-2.xsd"> | ||||||||||
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
<Appenders> | ||||||||||
<Console name="CONSOLE" target="SYSTEM_OUT"> | ||||||||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> | ||||||||||
</Console> | ||||||||||
<Sentry name="SENTRY" dsn="___PUBLIC_DSN___"/> | ||||||||||
</Appenders> | ||||||||||
|
||||||||||
<Loggers> | ||||||||||
<Root level="INFO"> | ||||||||||
<AppenderRef ref="CONSOLE"/> | ||||||||||
<AppenderRef ref="SENTRY" level="ERROR"/> | ||||||||||
</Root> | ||||||||||
</Loggers> | ||||||||||
|
||||||||||
</Configuration> | ||||||||||
``` | ||||||||||
|
||||||||||
`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. | ||||||||||
`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. | ||||||||||
|
||||||||||
### DSN Configuration | ||||||||||
|
||||||||||
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. | ||||||||||
|
||||||||||
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. | ||||||||||
|
||||||||||
```xml | ||||||||||
<Sentry name="Sentry" | ||||||||||
dsn="___PUBLIC_DSN___" /> | ||||||||||
<Sentry name="SENTRY" dsn="___PUBLIC_DSN___" /> | ||||||||||
``` | ||||||||||
|
||||||||||
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 +60,8 @@ Breadcrumbs are kept in memory (by default the last 100 records) and are sent wi | |||||||||
```xml | ||||||||||
<!-- Setting minimumBreadcrumbLevel modifies the default minimum level to add breadcrumbs from INFO to DEBUG --> | ||||||||||
<!-- Setting minimumEventLevel the default minimum level to capture an event from ERROR to WARN --> | ||||||||||
<Sentry name="Sentry" | ||||||||||
<Sentry name="SENTRY" | ||||||||||
dsn="___PUBLIC_DSN___" | ||||||||||
minimumBreadcrumbLevel="DEBUG" | ||||||||||
minimumEventLevel="WARN" | ||||||||||
/> | ||||||||||
minimumEventLevel="WARN"/> | ||||||||||
``` |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.