-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make exception logging in RequestLoggingMiddleware
optional
#341
Comments
It looks like you can disable particular log sources by Serilog's level overrides. |
I don't want to disable the log. I still want to see the log line |
I think this is doable, but we'd have to be careful about how we handle any exceptions captured by This pushes the setting name/semantics towards 🤔 |
Where/how is this |
Have there any updates regarding this issue? |
@cremor users can call Given the possible additional complications around logging cancellation exceptions, how about an enum for the option, which gives us some flexibility for future extensions? The final values for the
Initially we could consider implementing only the first and last, or some selection of those. |
I think this is a good idea. Some details:
|
Thanks for the feedback, sorry about the long delay, time has been a bit short :)
Yes, that's correct
Ah great, no need to worry about the task case explicitly, then.
Following the lead of those components sounds good.
Because the middleware has a different default today, and is very widely used, I don't think we'd default to |
Hope this can be implemented soon, would be very useful. |
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:
UseDeveloperExceptionPage
(or are running inDevelopment
hosting environment which enables this by default) then the exception is logged byMicrosoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware
.UseExceptionHandler
then the exception is logged byMicrosoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware
.Microsoft.AspNetCore.Server.Kestrel
.The text was updated successfully, but these errors were encountered: