diff --git a/CHANGELOG.md b/CHANGELOG.md index 97a3d669871..bb38633c0d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ - Allow multiple UncaughtExceptionHandlerIntegrations to be active at the same time ([#4462](https://github.com/getsentry/sentry-java/pull/4462)) - Prevent repeated scroll target determination during a single scroll gesture ([#4557](https://github.com/getsentry/sentry-java/pull/4557)) - This should reduce the number of ANRs seen in `SentryGestureListener` +- Do not use Sentry logging API in Log4j2 if logs are disabled ([#4573](https://github.com/getsentry/sentry-java/pull/4573)) + - This was causing Sentry SDK to log warnings: "Sentry Log is disabled and this 'logger' call is a no-op." ## 8.17.0 diff --git a/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java b/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java index a32af15e2ea..dddc6f3b902 100644 --- a/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java +++ b/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java @@ -191,7 +191,8 @@ public void start() { @Override public void append(final @NotNull LogEvent eventObject) { - if (eventObject.getLevel().isMoreSpecificThan(minimumLevel)) { + if (scopes.getOptions().getLogs().isEnabled() + && eventObject.getLevel().isMoreSpecificThan(minimumLevel)) { captureLog(eventObject); } if (eventObject.getLevel().isMoreSpecificThan(minimumEventLevel)) { diff --git a/sentry-samples/sentry-samples-log4j2/src/main/resources/sentry.properties b/sentry-samples/sentry-samples-log4j2/src/main/resources/sentry.properties index 47c00f6405f..b2310e08f89 100644 --- a/sentry-samples/sentry-samples-log4j2/src/main/resources/sentry.properties +++ b/sentry-samples/sentry-samples-log4j2/src/main/resources/sentry.properties @@ -1,2 +1,3 @@ in-app-includes="io.sentry.samples" logs.enabled=true +debug=true