-
Notifications
You must be signed in to change notification settings - Fork 207
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
RequestLoggingMiddleware sets the RequestPath property using IHttpRequestFeature.RawTarget #232
Comments
Thanks, I think this deserves a closer look 👍 |
Hi, I would like to follow up on this issue. Just wondering if it is reasonable to use Since the fallback code uses serilog-aspnetcore/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs Line 120 in abb94e9
|
Thanks for follow-up, @jarronshih. I guess the question to answer here is whether this will cause problems for users who already rely on the raw path value for monitoring etc. I hate to fall back on It'd also be nice to verify that the value we use, and |
@nblumhardt would you consider making a breaking change and not setting I saw you mention in another issue that query strings were not logged by design. Since
I believe this is the relevant code: |
Thanks for the pointer to the relevant code, @mjolka. I don't think we should skip setting some value for Switching to use ASP.NET Core's logic for constructing the path by default, and opting into the old behavior with |
@nblumhardt Thanks for the feedback. I update the PR which makes a new option and test it with |
Sorry about the delay on this, should have some time to take a look soon :-) |
Description
RequestLoggingMiddleware sets the RequestPath log event property using IHttpRequestFeature.RawTarget.
As a result, the RequestPath property in the log event emitted by RequestLoggingMiddleware can be different to that in a regular log event.
Reproduction
Configuration is standard:
Logging from the controller:
Expected behavior
I expect the RequestPath property in the event logged by RequestLoggingMiddleware to be equal to the RequestPath property in the event logged by the controller. However, the RequestPath property in the event logged by the controller includes the query string.
Relevant package, tooling and runtime versions
Serilog.AspNetCore 3.4.0.
Additional context
This behaviour can't be changed by the user because RequestLoggingMiddleware adds the RequestPath property after the call to EnrichDiagnosticContext.
RequestPath is already set in the request scope. It doesn't seem necessary for RequestLoggingMiddleware to set a value for it.
The text was updated successfully, but these errors were encountered: