Skip to content

Conversation

@Flash0ver
Copy link
Member

Fixes #4654


When the Serilog integration has captured an Event with an Exception, then

  • neither an additional Breadcrumb has been added (expected)
  • nor a Structured Log has been captured (unexpected)

This fix keeps the prevention of adding an additional Breadcrumb when an Event with an Exception has implicitly already added a Breadcrumb, but will still produce a Structured Log message (if enabled).
When an Event without an Exception does not implicitly add a Breadcrumb we still continue to explicitly add a Breadcrumb, while continuing to capture a Structured Log.

@Flash0ver Flash0ver self-assigned this Nov 4, 2025
@Flash0ver Flash0ver changed the base branch from main to version6 November 4, 2025 12:01
@Flash0ver
Copy link
Member Author

@sentry review

Comment on lines 106 to 107
var template = logEvent.MessageTemplate.Text;
var formatted = FormatLogEvent(logEvent);

This comment was marked as outdated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

-addedBreadcrumb
+addedBreadcrumbForException

to go in line with the Hub.AddBreadcrumbForException method, which is implicitly adding the Breadcrumb when an Exception is present.

@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (version6@a739982). Learn more about missing BASE report.

Additional details and impacted files
@@             Coverage Diff             @@
##             version6    #4691   +/-   ##
===========================================
  Coverage            ?   73.18%           
===========================================
  Files               ?      480           
  Lines               ?    17422           
  Branches            ?     3437           
===========================================
  Hits                ?    12751           
  Misses              ?     3821           
  Partials            ?      850           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Flash0ver Flash0ver marked this pull request as ready for review November 4, 2025 14:26

### Fixes

- The `Serilog` integration captures _Structured Logs_ (when enabled) independently of captured Events and added Breadcrumbs ([#4691](https://github.com/getsentry/sentry-dotnet/pull/4691))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: 6.0.0 vs 5.16.3

Do we want to publish this fix in a 5.16.3 patch release,
or is it fine to include in 6.0.0 as it's just a week away.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we plan to GA structured logging in version 5 of the SDK right? So doesn't make sense to backport the fix for this.

@Flash0ver Flash0ver changed the title Serilog/fix structured logging when exception fix: Serilog integration captures structured log when event with exception has been captured Nov 4, 2025
Copy link
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy - thanks @Flash0ver !

@jamescrosswell jamescrosswell merged commit 130650d into version6 Nov 4, 2025
32 checks passed
@jamescrosswell jamescrosswell deleted the serilog/fix-structured-logging-when-exception branch November 4, 2025 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Structured logs not being captured when exception attached.

3 participants