feat(logs): add NLog integration#5176
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5176 +/- ##
==========================================
+ Coverage 74.13% 74.19% +0.06%
==========================================
Files 508 510 +2
Lines 18282 18341 +59
Branches 3574 3583 +9
==========================================
+ Hits 13553 13609 +56
- Misses 3860 3862 +2
- Partials 869 870 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| log.TryGetAttribute("sentry.environment", out object? environment).Should().BeTrue(); | ||
| environment.Should().Be("test-environment"); | ||
| log.TryGetAttribute("sentry.release", out object? release).Should().BeTrue(); | ||
| release.Should().Be("test-release"); | ||
| log.TryGetAttribute("sentry.origin", out object? origin).Should().BeTrue(); | ||
| origin.Should().Be("auto.log.nlog"); | ||
| log.TryGetAttribute("sentry.sdk.name", out object? sdkName).Should().BeTrue(); | ||
| sdkName.Should().Be(Constants.SdkName); | ||
| log.TryGetAttribute("sentry.sdk.version", out object? sdkVersion).Should().BeTrue(); | ||
| sdkVersion.Should().Be(SentryTarget.NameAndVersion.Version); |
There was a problem hiding this comment.
suggestion: reference project Sentry.Testing and simplify assertions with extensions added in #4936
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f558baf. Configure here.
| if (Options.EnableLogs) | ||
| { | ||
| CaptureStructuredLog(hub, Options, logEvent); | ||
| } |
There was a problem hiding this comment.
NLog reads EnableLogs from wrong options source
High Severity
The NLog integration checks Options.EnableLogs (the target's own SentryNLogOptions) and passes Options to CaptureStructuredLog, but the Serilog integration explicitly reads from hub.GetSentryOptions() instead, with a detailed comment explaining why. When the SDK is initialized elsewhere (e.g., ASP.NET Core) and InitializeSdk is false, the NLog target's own Options.EnableLogs remains the default false, so structured logs silently won't be sent even though the user enabled them on the actual SDK options. The options passed to SetDefaultAttributes may also carry incorrect Environment/Release values.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f558baf. Configure here.


closes #5167
Changes
Add
NLogintegration to Sentry Structured Logging.Docs