Skip to content

Commit 2c9d584

Browse files
authored
No longer log a warning if a logging integration cannot initialize Sentry due to missing DSN. (#5075)
* Silence WARN from logging integrations/sdks when DSN is not configured * changelog
1 parent b6cfb57 commit 2c9d584

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
- When merging tombstones with Native SDK, use the tombstone message if the Native SDK didn't explicitly provide one. ([#5095](https://github.com/getsentry/sentry-java/pull/5095))
1212
- Fix thread leak caused by eager creation of `SentryExecutorService` in `SentryOptions` ([#5093](https://github.com/getsentry/sentry-java/pull/5093))
1313
- There were cases where we created options that ended up unused but we failed to clean those up.
14+
- No longer log a warning if a logging integration cannot initialize Sentry due to missing DSN ([#5075](https://github.com/getsentry/sentry-java/pull/5075))
15+
- While this may have been useful to some, it caused lots of confusion.
1416

1517
### Dependencies
1618

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ public void start() {
184184
Optional.ofNullable(transportFactory).ifPresent(options::setTransportFactory);
185185
});
186186
} catch (IllegalArgumentException e) {
187-
LOGGER.warn("Failed to init Sentry during appender initialization: " + e.getMessage());
187+
final @Nullable String errorMessage = e.getMessage();
188+
if (errorMessage == null || !errorMessage.startsWith("DSN is required.")) {
189+
LOGGER.warn("Failed to init Sentry during appender initialization: " + errorMessage);
190+
}
188191
}
189192
addPackageAndIntegrationInfo();
190193
super.start();

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ public void start() {
7171
try {
7272
Sentry.init(options);
7373
} catch (IllegalArgumentException e) {
74-
addWarn("Failed to init Sentry during appender initialization: " + e.getMessage());
74+
final @Nullable String errorMessage = e.getMessage();
75+
if (errorMessage == null || !errorMessage.startsWith("DSN is required.")) {
76+
addWarn("Failed to init Sentry during appender initialization: " + errorMessage);
77+
}
7578
}
7679
} else if (!Sentry.isEnabled()) {
7780
options

0 commit comments

Comments
 (0)