serilog / serilog-aspnetcore

Serilog integration for ASP.NET Core
Apache License 2.0
1.31k stars 205 forks source link

Do not log exception call stacks for cancellations in RequestLoggingMiddleware #372

Open cremor opened 4 months ago

cremor commented 4 months ago

Is your feature request related to a problem? Please describe. When a client cancels a request the RequestLoggingMiddleware will log the stack trace of the TaskCanceledException.

Describe the solution you'd like RequestLoggingMiddleware should not log exception strack traces for cancellations.

Describe alternatives you've considered Maybe make it configurable. But I can't see a reason why anyone would want stack traces for cancellations.

Additional context Related to #341 but not the same. You might want to log "real" exceptions but cancellation exceptions are always spam. This could be implemented in the same way as DeveloperExceptionPageMiddlewareImpl or ExceptionHandlerMiddlewareImpl implements it. It would be a good idea to also fix the status code for cancellations at the same time (related to #344).