You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
We use Hellang.Middleware.ProblemDetails to transform unhandled exceptions to ProblemDetails responses.
This means Serilog's RequestLoggingMiddleware does not observe any unhandled exceptions.
In order to log unhandled exceptions in our APIs, we currently use a separate error logging middleware.
This means we get two log events:
One from a custom ErrorLogMiddleware.
One from Serilog's request log middleware.
We would like to merge the exception data into Serilog's request log event by passing on the exception details via IDiagnosticContext.
Describe the solution you'd like
Add IDiagnosticContext.SetException(Exception e).
Add DiagnosticContextCollector.TryComplete(out IEnumerable<LogEventProperty>, out Exception)
Enrich log event with exception from IDiagnosticContext, unless an unhandled exception takes precedence.
Is your feature request related to a problem? Please describe.
We use Hellang.Middleware.ProblemDetails to transform unhandled exceptions to ProblemDetails responses.
This means Serilog's
RequestLoggingMiddleware
does not observe any unhandled exceptions.In order to log unhandled exceptions in our APIs, we currently use a separate error logging middleware.
This means we get two log events:
We would like to merge the exception data into Serilog's request log event by passing on the exception details via
IDiagnosticContext
.Describe the solution you'd like
IDiagnosticContext.SetException(Exception e)
.DiagnosticContextCollector.TryComplete(out IEnumerable<LogEventProperty>, out Exception)
IDiagnosticContext
, unless an unhandled exception takes precedence.Pull requests
serilog/serilog-extensions-hosting#56
#271
Describe alternatives you've considered
Separate error logging middleware, but then we get two log events instead of one.
Additional context
Current state:
Desired state with exception merged into Serilog's request log event:
The text was updated successfully, but these errors were encountered: