Skip to content
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

HttpLogging middleware should have an option to filter out endpoints #40950

Closed
grzegorz-wittchen opened this issue Mar 30, 2022 · 7 comments
Closed
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Needs: Design This issue requires design work before implementating. Status: Resolved

Comments

@grzegorz-wittchen
Copy link

I would suggest to implement a feature to filter requests for given endpoints which should be logged using that middleware.
F.e. right now as I wanted to log only data related to my API endpoints it's not possible. Enabling this middleware will log also all requests like for static files etc. creating a mess in my log.

@Tratcher
Copy link
Member

For static files at least, you can address that by changing the order of your middleware so logging comes after static files.

One way to go about this would be to put opt-in or opt-out attributes on specific endpoints. Another way (that we generally avoid) is having a callback, but people tend to re-invent routing in such callbacks.

@adityamandaleeka adityamandaleeka added the Needs: Design This issue requires design work before implementating. label Mar 30, 2022
@adityamandaleeka adityamandaleeka added this to the .NET 7 Planning milestone Mar 30, 2022
@ghost
Copy link

ghost commented Mar 30, 2022

Thanks for contacting us.

We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@akhmolina
Copy link

This feature will be useful for filter out healthchecks calls with 200 status code in kubernetes

@Tratcher
Copy link
Member

Tratcher commented Sep 9, 2022

Making the middleware endpoint aware could address this. #43222

@ghost
Copy link

ghost commented Sep 9, 2022

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@stefer
Copy link

stefer commented Nov 18, 2022

It is possible to use UseWhen to selectively add http logging to only some endpoints, like so:

            app.UseWhen(
                context => context.Request.Path.StartsWithSegments("/api"),
                builder => builder.UseHttpLogging());

@Tratcher
Copy link
Member

@Tratcher Tratcher closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2023
@Tratcher Tratcher added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Feb 24, 2023
@ghost ghost added the Status: Resolved label Feb 24, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Mar 27, 2023
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Needs: Design This issue requires design work before implementating. Status: Resolved
Projects
None yet
Development

No branches or pull requests

7 participants