feat: log4net appender no longer initializes the SDK - #5592
Draft
jamescrosswell wants to merge 1 commit into
Draft
jamescrosswell wants to merge 1 commit into
jamescrosswell wants to merge 1 commit into
Conversation
The Sentry appender for log4net now only sends log events to Sentry. Sentry must be initialized separately (SentrySdk.Init, UseSentry, etc). - Remove SentryAppender.Dsn and the lazy SDK initialization on first append - Remove SentryAppender.Environment; events take the environment from the options used to initialize Sentry - Remove the OnClose override, which only disposed the SDK the appender had initialized Part of #5245 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 @@
## feat/no-init-from-logging-nlog-5245 #5592 +/- ##
=======================================================================
- Coverage 74.58% 74.56% -0.03%
=======================================================================
Files 514 514
Lines 18745 18728 -17
Branches 3646 3641 -5
=======================================================================
- Hits 13981 13964 -17
Misses 3891 3891
Partials 873 873 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
The log4net portion of #5245, stacked on #5585 (NLog) and following the same design. The Sentry appender for log4net now only sends log events to Sentry; Sentry has to be initialized separately via
SentrySdk.Init,UseSentry, etc.Part of #5245
Breaking changes
SentryAppender.Dsnis removed, along with the appender initializing the SDK on the first append.SentryAppender.Environmentis removed. Events and structured logs take the environment from the options used to initialize Sentry.SentryAppenderno longer overridesOnClose. It only existed to dispose the SDK the appender had initialized, so closing the log4net repository no longer flushes Sentry; disposing the handle fromSentrySdk.Initdoes.<Dsn>or<Environment>on the appender keep loading. log4net reports each one through its internal logging (log4net:ERROR XmlHierarchyConfigurator: Cannot find Property [Dsn] to set object on [Sentry.Log4Net.SentryAppender]) and applies the remaining properties, but Sentry is no longer initialized.Before:
After:
Notes for review
Dsnwas set.IsEnabled == false, and events were only captured because the mocked init had run.UseLog4Net(): identity, properties and the SDK name are all applied by the appender to the events and logs it creates.SendIdentityandMinimumEventLevelstay; they configure what the appender sends, not the SDK.ApiApprovalTests.Run.Net4_8andDotNet10_0are copies of the regeneratedDotNet11_0snapshot, which all three matched byte-for-byte beforehand.Net4_8can't regenerate on macOS, andDotNet10_0isn't run at all since the test project only targets the latest TFM.🤖 Generated with Claude Code