Skip to content

Add ExceptionHandlerOptions.SuppressLoggingOnHandledException #59075

Open
@JamesNK

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.

Risks

Metadata

Assignees

No one assigned

    Labels

    api-ready-for-reviewAPI is ready for formal API review - https://github.com/dotnet/apireviewsarea-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlesware

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions