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

Optionally log POST request body #1880

Closed
kendaleiv opened this issue May 28, 2020 · 7 comments
Closed

Optionally log POST request body #1880

kendaleiv opened this issue May 28, 2020 · 7 comments

Comments

@kendaleiv
Copy link

Previously reported here: microsoft/ApplicationInsights-aspnetcore#686

Sounds like it may be happening per microsoft/ApplicationInsights-aspnetcore#686 (comment) but didn't want it to fall off the radar for those who would find it useful.

@cijothomas
Copy link
Contributor

Its not lost! its among the top asks in uservoice!
Unfortunately, this is not going to be supported by the ApplicationInsights SDK in this year.

The current suggestion/workaround is for customers to write the RequestBody using Ilogger. And have application insights capture the ilogger trace. Since ilogger traces gets automatically correlated with Request telemetry, it should be possible to find the body.

@leninc
Copy link

leninc commented Jun 23, 2020

Hi @cijothomas! do you happen to have a sample for the item above, i have an mvc project in 4.6 that i want to be able to log the request and response to app insights and not sure what approach to take based on the comment here.

Regards

@cijothomas
Copy link
Contributor

@leninc The recommendation currently is:
Get request/response body - log it using ilogger instance.
Configure application insights to capture it - if the ilogger is logged at Warning level or above, the Application Insights collects it by default. Else modify filters to capture it. (https://docs.microsoft.com/en-us/azure/azure-monitor/app/ilogger#control-logging-level)

I don't have working sample to correctly capture request/response body.
For logging with Ilogger, the official docs has examples.

@leninc
Copy link

leninc commented Jun 24, 2020

@cijothomas thanks for the quick response, will look into this

@github-actions
Copy link

This issue is stale because it has been open 300 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@cijothomas
Copy link
Contributor

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-logging/?view=aspnetcore-6.0 .New middleware from asp.net core 6.0 makes this easy to do.

@Postlagerkarte
Copy link

@cijothomas I activated the new HttpLogging middleware, can see the output from it in my console window, however it is not visible/attached to my App Insights. What am I missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants