Skip to content

Getting event id from microsoft logging extension integration #1331

Answered by bruno-garcia
HaydnDias asked this question in Q&A
Discussion options

You must be logged in to vote

You can get the id via SentrySdk.LastEventId. This value is backed by a AsyncLocal so it should include the value of the event id you have just captured, e.g:

_logger.LogError(..);
var sentryId = SentrySdk.LastEventId;

if you don't want to couple your code with the static class SentrySdk you can take via DI IHub. More on the docs.

SentryId LastEventId { get; }

But since you're already taking IHub via DI (or using SentrySdk), an alternative is:

var sentryId = _hub.CaptureException(ex);

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@HaydnDias
Comment options

@HaydnDias
Comment options

@bruno-garcia
Comment options

Answer selected by mattjohnsonpint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants