UseExceptionHandler
causes Serilog to write uncaught exceptions twice into the request log.
#260
Labels
UseExceptionHandler
causes Serilog to write uncaught exceptions twice into the request log.
#260
Description
When
UseExceptionHandler
is combined withUseSerilogRequestLogging
, every time an uncaught exception occurs, two 500 error lines are written into the request log.Reproduction
This sample code more or less follows what is posted in the README:
Program.cs:
Startup.cs:
TestController.cs:
Running the project and then making a HTTP request to
http://localhost:5000
results in the following entries being written into the log file:Ignoring the stack traces, note that there are two different lines that both read
HTTP GET / responded 500 in xx.xxxx ms
, except the number of milliseconds differs.Expected behavior
Since there was only a single HTTP request made and a single exception thrown, I would expect a single 500 error line to get written into the request log, not two. Why is the error line getting repeated? This makes things rather misleading when analyzing our logs.
Relevant package, tooling and runtime versions
Serilog 2.10.0, Serilog.AspNetCore 4.1.0, .NET 5.0
The text was updated successfully, but these errors were encountered: