Skip to content

Make exception logging in RequestLoggingMiddleware optional #341

Open
@cremor

Description

@cremor

Is your feature request related to a problem? Please describe.
If my application uses UseSerilogRequestLogging all unhandled exceptions are logged twice. This causes logs to be more long/complicated than they need to be.

Describe the solution you'd like
RequestLoggingOptions should have an option to not log the exception.

Describe alternatives you've considered
Maybe exception logging should even be disabled by default since I couldn't find any case where the exception isn't logged by something else.

Additional context
There are multiple other classes which already log the exception, depending on your middleware configuration:

  • If you use UseDeveloperExceptionPage (or are running in Development hosting environment which enables this by default) then the exception is logged by Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.
  • If you use UseExceptionHandler then the exception is logged by Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.
  • If you use neither then the exception is logged by Microsoft.AspNetCore.Server.Kestrel.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions