Getting event id from microsoft logging extension integration #1331
-
Hi, we're using sentry with microsoft logging by catching errors and calling ILogger.LogError(...etc), but we'd like to be able to get the event id for that log to return with api's/provide to consumers for tracing and reporting, is there a simple way to get this in the same context reliably? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You can get the id via
if you don't want to couple your code with the static class sentry-dotnet/src/Sentry/IHub.cs Line 23 in ad9f5ff But since you're already taking
|
Beta Was this translation helpful? Give feedback.
You can get the id via
SentrySdk.LastEventId
. This value is backed by aAsyncLocal
so it should include the value of the event id you have just captured, e.g:if you don't want to couple your code with the static class
SentrySdk
you can take via DIIHub
. More on the docs.sentry-dotnet/src/Sentry/IHub.cs
Line 23 in ad9f5ff
But since you're already taking
IHub
via DI (or using SentrySdk), an alternative is: