Share via


ExceptionHandlerOptions.SuppressDiagnosticsCallback Property

Definition

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 UnhandledException to ILogger.
  • Writing the Microsoft.AspNetCore.Diagnostics.HandledException event to EventSource.
  • Adding the error.type tag to the http.server.request.duration metric.
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)

Property Value

Applies to