当前位置: 首页 > 知识库问答 >
问题:

记录应用程序洞察的请求和响应

丁经国
2023-03-14

我正在尝试将API请求负载和响应数据记录到Azure Application Insight。使用跟踪我可以记录。但是我想知道什么是将请求和响应数据记录到application Insight的最佳方法。因为数据是巨大的,所以API调用的数量会更多。我不能仅仅使用跟踪来跟踪数十万个请求和响应数据。我尝试了一些博客,比如使用itelemetryinitializer/httpcontext.feature和get,但没有成功。

public class AzureRequestResponseInitializer : ITelemetryInitializer
{
    public void Initialize(ITelemetry telemetry)
    {
        var requestTelemetry = telemetry as RequestTelemetry;
        
        if (requestTelemetry != null && (HttpContext.Current.Request.HttpMethod == HttpMethod.Post.ToString() || HttpContext.Current.Request.HttpMethod == HttpMethod.Get.ToString()))
        {
            using (var reader = new StreamReader(HttpContext.Current.Request.InputStream))
            {
                string requestBody = reader.ReadToEnd();
                requestTelemetry.Properties.Add("body", requestBody);
            }
        } 

共有1个答案

鞠泰平
2023-03-14

https://thirum.wordpress.com/2019/08/19/logging-the-http-response-body-in-application-insights/

请看一下。

 类似资料:
  • 有什么想法会出什么问题吗?

  • 我们有一个使用Play框架的Java web应用程序。如何使用应用程序洞察添加web请求日志记录?其他项目类型的文档可用https://docs.microsoft.com/en-us/azure/azure-monitor/app/java-get-start#4-add-an-http-filter

  • 有没有什么简单的方法可以找到哪些应用程序正在使用azure Portal的特定应用程序洞察? 我已经检查了门户中的各种选项,但没有找到任何易于理解的界面,我可以在其中找到正在向特定应用程序Insights发送数据的应用程序列表。

  • 我们为Azure Portal中托管的Web应用程序安装了应用程序Insights。

  • 我正在尝试配置我的azure ASP.NET网站,以便将log4net跟踪发送到azure Application Insights。我可以看到在我的azure控制台页面视图等,因此我知道这是工作良好的。当配置了文件处理程序时,我还可以看到log4net跟踪,但是当配置log4net以使用application insights处理程序时,我没有看到任何log4net条目出现在applicatio

  • 问题内容: 我想记录一个axis2客户端发出的所有请求/响应。我试图在http://code.google.com/support/bin/answer.py?hl=zh_CN&answer=15137中创建一个称为describer 的文件,但没有成功(我没有日志文件)。 请求是通过https发出的,我不确定是否重要。我试过了 和 没有成功。 问题答案: 对于SOAP消息的Axis2客户端日志记