Is there a way we can see/log the actual forward proxy request's details? #2205
-
dotnet 7
yarp 2.0.1 Hello! Just like the However, i am struggling to log the details of the actual request that is being sent out by YARP. The closest I can get is by referencing the It seems like a simple thing to see when using YARP, but I think I am definitely overlooking something that may be obviously available - so some help here is really appreciated 🙂 P.S.: Yes - I have tried searching the YARP repo, this discussion forum, YARP's documentation, search engine & chatGPT 😅 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
UPDATE: I think I may have found one way to access the forward proxy request by using a Custom Transformer as described here and then use However, this seems to require moving away from the regular |
Beta Was this translation helpful? Give feedback.
-
What information about the request are you looking to log? There is nothing similar to
You don't have to write a whole services.AddReverseProxy()
.AddTransforms(transformBuilderContext =>
{
transformBuilderContext.AddRequestTransform(context =>
{
_logger.LogInformation("...", context.ProxyRequest.RequestUri.AbsoluteUri);
return ValueTask.CompletedTask;
});
}); See https://microsoft.github.io/reverse-proxy/articles/transforms.html If you are interested in logging the request body, I think the best option is to let ASP.NET Core's Http Logging do it for you. |
Beta Was this translation helpful? Give feedback.
-
Is there any way to see the egress request after transforms? I am working with @ChintanRaval and we are now looking to compare headers on the ingress request vs headers on the egress request. One thing I tried was using a middleware but the request on the Thank you. |
Beta Was this translation helpful? Give feedback.
What information about the request are you looking to log?
Things like Uri/Host/Headers, or also the request body of POST requests?
There is nothing similar to
UseHttpLogging
built in, but most of the information on the outgoing request should be very similar to the original request that came in (minus Uri and header modifications done with transforms).You don't have to write a whole
HttpTransformer
or move to direct forwarding to do so.E.g.