ExceptionHandlerOptions.SuppressDiagnosticsCallback Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a callback that can return true to suppress diagnostics in ExceptionHandlerMiddleware.
If SuppressDiagnosticsCallback is null, the default behavior is to suppress diagnostics if the exception was handled by
an IExceptionHandler service instance registered in the DI container.
To always record diagnostics for handled exceptions, set a callback that returns false.
This callback is only run if the exception was handled by the middleware. Unhandled exceptions and exceptions thrown after the response has started are always logged.
Suppressed diagnostics include:
- Logging
UnhandledExceptionto ILogger. - Writing the
Microsoft.AspNetCore.Diagnostics.HandledExceptionevent to EventSource. - Adding the
error.typetag to thehttp.server.request.durationmetric.
public Func<Microsoft.AspNetCore.Diagnostics.ExceptionHandlerSuppressDiagnosticsContext,bool>? SuppressDiagnosticsCallback { get; set; }
member this.SuppressDiagnosticsCallback : Func<Microsoft.AspNetCore.Diagnostics.ExceptionHandlerSuppressDiagnosticsContext, bool> with get, set
Public Property SuppressDiagnosticsCallback As Func(Of ExceptionHandlerSuppressDiagnosticsContext, Boolean)