feat: Logs sent via SentrySdk.Logger no longer require EnableLogs - #5512
Merged
Conversation
Reaching for `SentrySdk.Logger` (or any `SentryStructuredLogger`) is already an explicit statement that you want those logs in Sentry, so requiring `EnableLogs = true` on top of it was an unnecessary hoop. Deliberately scoped to that API. The logging integrations (`Sentry.Extensions.Logging`, `Sentry.Serilog`, `Sentry.NLog`, `Sentry.Log4Net`) each gate on `EnableLogs` themselves before calling `hub.Logger.CaptureLog`, so they are unaffected and continue to honour the option. Those instrument a general-purpose `ILogger`-style surface where intent is far less clear, and they also produce breadcrumbs and events - so changing them is a breaking change, left for the next major version. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5512 +/- ##
==========================================
- Coverage 74.74% 74.72% -0.03%
==========================================
Files 513 513
Lines 18829 18827 -2
Branches 3682 3681 -1
==========================================
- Hits 14074 14068 -6
- Misses 3875 3878 +3
- Partials 880 881 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jamescrosswell
commented
Aug 27, 2026
jamescrosswell
commented
Aug 27, 2026
jamescrosswell
commented
Aug 27, 2026
Co-authored-by: James Crosswell <jamescrosswell@users.noreply.github.com>
6c8fb7a removed the first line of the "To filter or drop those, use SetBeforeSendLog and return null" sentence but left the second, so the remarks ended mid-sentence with "and return null.". Completing that removal. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
jamescrosswell
marked this pull request as ready for review
August 27, 2026 04:22
dingsdax
self-requested a review
August 27, 2026 05:18
dingsdax
approved these changes
Aug 27, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Phase 1 of #5479, split out of #5504.
Summary
Reaching for
SentrySdk.Logger(or anySentryStructuredLogger) is already an explicit statement that you want those logs in Sentry, so requiringEnableLogs = trueon top of it was an unnecessary hoop. That gate is gone.The whole change is one branch in
SentryStructuredLogger.Create:What this deliberately does not change
SentryOptions.EnableLogsstays, still defaults tofalse, and is not obsolete. The logging integrations —Sentry.Extensions.Logging,Sentry.Serilog,Sentry.NLog,Sentry.Log4Net— each checkEnableLogsthemselves before callinghub.Logger.CaptureLog(...), so they are entirely unaffected and continue to honour the option.That is what makes this seam clean: the integrations sit in front of the gate being removed, not behind it. The evidence is that not a single Verify snapshot or API-approval file changed — if any integration had started emitting logs, the
Simple/Versioningsnapshots would have moved, as they did in #5504.Leaving them alone is deliberate rather than incidental. Those integrations instrument a general-purpose
ILogger-style surface where "I configured logging" says much less about whether you want the logs in Sentry, and each one produces three different things from a single log call — breadcrumbs, events, and structured logs. Changing that is a breaking change, so it belongs in the next major version.The option's XML doc now says exactly which of the two it governs.
Notes for review
Sentry.Samples.Console.Basicused the direct API only, and its comment claimed the option "enables Sentry Logs created via SentrySdk.Logger" — no longer true, so both are gone. Every other sample uses a logging integration and keepsEnableLogs = trueuntouched.HubTestscases described the option toggling this API and no longer have any meaning;Logger_IsDisabled_DoesNotCaptureLogis replaced byLogger_EnableLogsDisabled_StillCapturesLog, asserting the new behaviour directly.Create_EnableLogsDisabled_NewDefaultInstancecovers the same at the factory.EnableLogsstill gates them (SentrySinkTests.Emit_StructuredLogging_IsEnabled,SentryAppenderTests.DoAppend_StructuredLogging_IsEnabled,SentryStructuredLoggerTests.IsEnabled_HubAndOptions_Returns) are untouched and now serve as the guard against this phase leaking into the next.CHANGELOG.mdentry —scripts/verify-changelog.shrejects manual## Unreleasedsections, so the commit subject is the changelog line.🤖 Generated with Claude Code