When implementing my own Exception handler using app.UseExceptionHandler with an exception handler lambda / delegate (Documentation) I do not want Microsofts Exception handler middleware to log this error:
An unhandled exception has occurred while executing the request.
This exception message clutters my log file because I take care of logging the exception with an appropriate LogLevel by myself.
This is how I register my own ErrorHandler:
app.UseExceptionHandler(errorApp =>
errorApp.Run(ErrorHandler));
As described in this issue filtering this exact message and nothing else is not possible in a simple way.
How do I filter this exact log message and nothing else from the middleware?
I am using:
- ASP.NET Core 3.1
- Serilog 3.4.0