feat(logs): add log4net integration - #5172
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5172 +/- ##
==========================================
+ Coverage 74.23% 74.61% +0.37%
==========================================
Files 509 512 +3
Lines 18435 18540 +105
Branches 3610 3617 +7
==========================================
+ Hits 13685 13833 +148
+ Misses 3875 3834 -41
+ Partials 875 873 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Flash0ver
marked this pull request as ready for review
May 18, 2026 11:19
Flash0ver
commented
May 18, 2026
Collaborator
|
@Flash0ver I put this back in draft state until CI passes. Looks like there is some warden feedback worth checking as well. |
jamescrosswell
marked this pull request as draft
June 23, 2026 01:24
…n tests - Fall back to string.Empty when RenderedMessage is null, matching the existing non-structured path (review r3258513795). - Clear ThreadContext.Properties in test teardown so thread-static entries don't leak into subsequent tests (review r3258530109). - Adapt CaptureStructuredLog to the SetDefaultAttributes(options, scope, sdk) signature introduced on main, passing the active scope for enrichment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… extensions Use the SentryAttributes.ShouldContain extensions added in #4936 instead of the verbose TryGetAttribute/Should().Be pairs (review r3258494145). Grants Sentry.Log4Net.Tests access to Sentry.Testing internals. The collection assertion keeps BeEquivalentTo since the extension compares by value equality. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jamescrosswell
marked this pull request as ready for review
July 15, 2026 22:55
Brings the log4net structured-log path in line with the MEL integration, which sets category.name from the logger/category name. Previously the log4net logger name was only surfaced on the legacy SentryEvent.Logger. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The sample only targets net481, so the #if NETFRAMEWORK conditional is always true. Remove it and keep the SetPrincipalPolicy call unconditionally. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… file Move the Create factory method into SentryLog.cs, drop the now-unneeded partial modifier, and remove the SentryLog.Factory.cs DependentUpon entry from the csproj. A single method doesn't warrant its own file. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Invert the level check into a pattern-matched guard clause that returns early, removing a level of nesting and folding the null check into the assignment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jul 27, 2026
evgenygunko
pushed a commit
to evgenygunko/CopyWordsDA
that referenced
this pull request
Jul 27, 2026
> ℹ️ **Note** > > This PR body was truncated due to platform limits. This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [Sentry.Maui](https://sentry.io/) ([source](https://github.com/getsentry/sentry-dotnet)) | `6.7.0` → `6.8.0` |  |  | --- ### Release Notes <details> <summary>getsentry/sentry-dotnet (Sentry.Maui)</summary> ### [`v6.8.0`](https://github.com/getsentry/sentry-dotnet/blob/HEAD/CHANGELOG.md#680) [Compare Source](getsentry/sentry-dotnet@6.7.0...6.8.0) ##### Features ✨ ##### Logs - feat(logs): add `log4net` integration by [@​Flash0ver](https://github.com/Flash0ver) in [#​5172](getsentry/sentry-dotnet#5172) - feat(logs): add `NLog` integration by [@​Flash0ver](https://github.com/Flash0ver) in [#​5176](getsentry/sentry-dotnet#5176) ##### Other - feat(serilog): support restrictedToMinimumLevel when configuring Serilog in code by [@​jamescrosswell](https://github.com/jamescrosswell) in [#​5181](getsentry/sentry-dotnet#5181) - Attachments can now be sent with transactions by setting `AddToTransactions` on `SentryAttachment` [#​5182](getsentry/sentry-dotnet#5182) by [@​jamescrosswell](https://github.com/jamescrosswell) in [#​5182](getsentry/sentry-dotnet#5182) - Added `SentrySdk.RecordTransaction` to record already-completed transactions and spans (e.g. replayed through a proxy) [#​5333](getsentry/sentry-dotnet#5333) by [@​jamescrosswell](https://github.com/jamescrosswell) in [#​5333](getsentry/sentry-dotnet#5333) - The `Environment` set on the `Scope` now gets synchronized to the native layers (`sentry-cocoa` and `sentry-native`) by [@​bitsandfoxes](https://github.com/bitsandfoxes) in [#​5365](getsentry/sentry-dotnet#5365) ##### Fixes 🐛 - fix: `SentrySpanProcessor` no longer leaks spans whose Activity never ends (e.g. aborted requests); the Activity is now held via a `WeakReference` so orphaned spans are pruned once it is garbage-collected. by [@​Ermabo](https://github.com/Ermabo) in [#​5393](getsentry/sentry-dotnet#5393) - The SDK was incorrectly ignoring server rate limits for errors, check-ins, and logs by [@​jamescrosswell](https://github.com/jamescrosswell) in [#​5412](getsentry/sentry-dotnet#5412) - fix: BackpressureMonitor.Dispose() no longer deadlocks on single-threaded targets by [@​jamescrosswell](https://git...
This was referenced Jul 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.
closes #4731
Changes
Add
log4netintegration to Sentry Structured Logging.Docs
See also
Implementation Notes
Sentry's log4net support is a log4net appender (
SentryAppender : AppenderSkeleton). Every log call flows throughAppend(LoggingEvent).Previously each event became either a
SentryEvent(error) or a breadcrumb. Now, whenoptions.EnableLogsis on,Appendalso callsCaptureStructuredLogto emit a Sentry structured log.log4net-specific stuff
1. Level mapping. log4net doesn't have a clean enum — it has ~18 named
Levelobjects (All, Finest, Verbose, Finer, Trace, Fine, Debug, Info, Notice, Warn, Error, Severe, Critical, Alert, Fatal, Emergency, …) plus user-defined custom levels with arbitrary integer values.ToSentryLogLevelcollapses all that into Sentry's 6 levels using>=threshold comparisons on the numeric value, so custom levels land in the nearest bucket andLevel.Offdrops the log (returnsnull).2. Message: rendered only. log4net pre-renders the final string into
LoggingEvent.RenderedMessage, which becomes the logMessage.3. No template, no parameters. log4net can't give us the original template of parameters:
log4net's message object is typically a
SystemStringFormatthat keeps the composite format string ("{0} {1}") and the args array as private fields with no public accessor. This is a limitation of log4net rather than Sentry's integration.4. Properties →
property.*attributes, with log4net-specific filtering. log4net merges event-level properties,ThreadContext.Properties,GlobalContext.Properties, and its own metadata into one bag viaGetProperties(). The loop (Structured.cs:20-29) maps eachDictionaryEntryto aproperty.<key>attribute, skipping:log4net:(log4net's internal entries — HostName, Identity, etc.),This
property.<key>convention matches Serilog, not MEL. (MEL doesn't have an ambient property bag — it emits parameters pluscategory.name/event.id/event.name.)