Add ExceptionHandlerOptions.SuppressLoggingOnHandledException
#59075
Open
Description
Background and Motivation
A config option to only log in exception handler middleware if the exception is unhandled.
For #54554
Proposed API
namespace Microsoft.AspNetCore.Builder;
public class ExceptionHandlerOptions
{
+ public bool SuppressLoggingOnHandledException { get; set; }
}
Defaults to false.
Usage Examples
app.UseExceptionHandler(new ExceptionHandlerOptions()
{
SuppressLoggingOnHandledException = true
});
Alternative Designs
Could make the new behavior the default. I don't think that is a good idea for backwards compatibility reasons, and some people might prefer the current behavior.