简体   繁体   English

如何在 Azure Application Insights 中使用 BeginScope(在 https://portal.azure.com 中)?

[英]How to use BeginScope in Azure Application Insights (in https://portal.azure.com)?

My C# code is log.BeginScope("Testing Scope1");我的 C# 代码是log.BeginScope("Testing Scope1"); and log.BeginScope("Testing Scope2");log.BeginScope("Testing Scope2"); . . How can I use in Azure Application Insights (in https://portal.azure.com )?我如何在 Azure Application Insights 中使用(在https://portal.azure.Z4D5Z56D9A2DDABEC )中

If your code like below:如果您的代码如下所示:

        using (_logger.BeginScope("Testing Scope1"))
        {
            _logger.LogInformation("this is an info from index page 111111");
        }

Then, after the code is executed, nav to azure portal -> your application insights -> Logs -> in the traces table, write the following query(also note that select a proper "time range"):然后,在执行代码后,导航到 azure 门户 -> 您的应用程序洞察 -> 日志 -> 在traces表中,编写以下查询(还要注意 select 是一个适当的“时间范围”):

traces
| where customDimensions.Scope contains "Testing Scope1"
| project message, customDimensions

The screenshot is as below:截图如下:

在此处输入图像描述

By the way, it may take a few minutes for the logs being generated.顺便说一句,生成日志可能需要几分钟。 And please also set the proper log level in your application(like set the proper log level in your azure function ).并且请在您的应用程序中设置正确的日志级别(例如在 azure function 中设置正确的日志级别)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 portal.azure.com 中按类型默认概览仪表板 - How to default overview dashboard as group by type in portal.azure.com 从 portal.azure.com 阻止用户 - Block user from portal.azure.com 通过 https://portal.azure.com 导出 Azure SQL 永远不会完成 - Azure SQL Export via https://portal.azure.com Never Completes portal.azure.com 中的 Azure 应用服务运行时堆栈可用性 - Azure App Service Runtime Stack Availability in portal.azure.com 我可以在https://portal.azure.com仪表板上的markdown小部件中添加较大的Font文本吗? - Can I add larger Font text to the markdown widget on https://portal.azure.com dashboard? manage.windowsazure.com与portal.azure.com - manage.windowsazure.com vs. portal.azure.com .NET应用程序见解| 自定义指标未显示在portal.azure.com中的指标下 - Application insight .NET | Custom metrics don't show up in portal.azure.com under metrics portal.azure.com WebApp面板,无信息/标签 - portal.azure.com WebApp Panel without info/tabs 无法在portal.azure.com中删除存储帐户 - Failed to delete storage account in portal.azure.com 如何通过portal.azure.com将用户添加到我的AAD租户? - How Do I Add a User to My AAD Tenant via portal.azure.com?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM