当前位置: 动力学知识库 > 问答 > 编程问答 >

azure - Track HTTP body content on Application Insights

问题描述:

Is there any way to include the HTTP Body response content in Application Insights HTTP or dependency tracking modules? Its useful knowing what the HTTP response status code of a request is, but its really important us to know what the response message/data.

Ive looked at creating a custom Filter or Initializer but no properties seem to have any response content, how can I include it?

网友答案:

This actually requires a bit more than inspecting the properties of your Response object. You will have to use a Response Filter in order to capture the body before it's done.

The gist below has two files. One is the CaptureStream.cs file that implements a Stream abastract class and just passes along the information. Along the way we append data in a StringBuilder.

In the other is just an example of a Global.asax.cs that overrides the Application_BeginRequest method and the Application_LogRequest method.

You can choose any method in the ASP.NET Application Lifecycle that you think is the right location. I chose these two because it was the first two I remember using in other projects.

https://gist.github.com/debugthings/058f8c0634accfbdcce2c8c5b818d514

分享给朋友:
您可能感兴趣的文章:
随机阅读: