Skip to content

Commit 6c58c54

Browse files
Do not use Sentry logging API in Log4j2 if logs are disabled (#4573)
* Do not use Sentry logging API if logs are disabled * Format code * changelog * mention log4j2 in changelog entry --------- Co-authored-by: Sentry Github Bot <[email protected]>
1 parent d1fd194 commit 6c58c54

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
- Allow multiple UncaughtExceptionHandlerIntegrations to be active at the same time ([#4462](https://github.com/getsentry/sentry-java/pull/4462))
2727
- Prevent repeated scroll target determination during a single scroll gesture ([#4557](https://github.com/getsentry/sentry-java/pull/4557))
2828
- This should reduce the number of ANRs seen in `SentryGestureListener`
29+
- Do not use Sentry logging API in Log4j2 if logs are disabled ([#4573](https://github.com/getsentry/sentry-java/pull/4573))
30+
- This was causing Sentry SDK to log warnings: "Sentry Log is disabled and this 'logger' call is a no-op."
2931

3032
## 8.17.0
3133

sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ public void start() {
191191

192192
@Override
193193
public void append(final @NotNull LogEvent eventObject) {
194-
if (eventObject.getLevel().isMoreSpecificThan(minimumLevel)) {
194+
if (scopes.getOptions().getLogs().isEnabled()
195+
&& eventObject.getLevel().isMoreSpecificThan(minimumLevel)) {
195196
captureLog(eventObject);
196197
}
197198
if (eventObject.getLevel().isMoreSpecificThan(minimumEventLevel)) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
in-app-includes="io.sentry.samples"
22
logs.enabled=true
3+
debug=true

0 commit comments

Comments
 (0)