azure - 如何在 Azure Application Insights 中使用 BeginScope(在 https://portal.azure.com 中)?
问题描述
我的 C# 代码是log.BeginScope("Testing Scope1");
和log.BeginScope("Testing Scope2");
. 如何在 Azure Application Insights 中使用(在https://portal.azure.com中)?
解决方案
如果您的代码如下所示:
using (_logger.BeginScope("Testing Scope1"))
{
_logger.LogInformation("this is an info from index page 111111");
}
然后,在代码执行后,导航到 azure 门户 -> 你的应用程序洞察 -> 日志 -> 在traces
表中,编写以下查询(还要注意选择适当的“时间范围”):
traces
| where customDimensions.Scope contains "Testing Scope1"
| project message, customDimensions
截图如下:
顺便说一句,生成日志可能需要几分钟。并且请在您的应用程序中设置正确的日志级别(例如在您的 azure 函数中设置正确的日志级别)。
推荐阅读
- c++ - C++“字符串下标超出范围”问题
- javascript - 具有不透明度的 Amcharts 网格颜色
- java - wsdl2java 生成列表
> 而不是属性 - c++ - 不可预测的复制省略?
- python - 将 3D 数组拆分为固定维度的较小块的 Pythonic 方法
- android - 当我尝试更改活动时,我的 android 应用程序崩溃了
- android - JSON 数组到数据模型
- pandas - 为 Pandas 数据框单元格中的列表元素编写 if 语句
- javascript - 无法匹配 mongodb 聚合中的 objectId 数组
- flutter - 颤振:无法从pdf文件打开特定页面