Default ExceptionHandlerMiddleware should have an option to suppress log output #46962
Closed
1 task done
Labels
area-middleware
Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware
feature-diagnostics
Diagnostic middleware and pages (except EF diagnostics)
Is there an existing issue for this?
Describe the bug
This is has been reported before here: #42950
The suggested resolution was to set log level to
None
forMicrosoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware
. Whilst this kind of works, I think it's a pretty terrible solution.First, it semantically looks - from a glance at log levels - like you don't want exceptions logged. And this is just because you (in your custom exception handling middleware, registered in
app.UseExceptionHandler
) are logging exceptions in a way you want, instead of leaving it toExceptionHandlerMiddleware
.Second, if some third-party exception handling middleware is registered in the pipeline, it can't control the log levels, so you'll have to manually suppress
ExceptionHandlerMiddleware
's logs via the log levels. This is messy.Expected Behavior
Middleware registered via
app.UseExceptionHandler()
should have a way to completely suppress error logging made byExceptionHandlerMiddleware
, and considering a custom exception handler is quite likely to make its own logs, that suppression should maybe even be the default. Nevertheless, it should be an option.Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: