簡體   English   中英

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

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

我的 C# 代碼是log.BeginScope("Testing Scope1"); log.BeginScope("Testing Scope2"); . 我如何在 Azure Application Insights 中使用(在https://portal.azure.Z4D5Z56D9A2DDABEC )中

如果您的代碼如下所示:

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

然后,在執行代碼后,導航到 azure 門戶 -> 您的應用程序洞察 -> 日志 -> 在traces表中,編寫以下查詢(還要注意 select 是一個適當的“時間范圍”):

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

截圖如下:

在此處輸入圖像描述

順便說一句,生成日志可能需要幾分鍾。 並且請在您的應用程序中設置正確的日志級別(例如在 azure function 中設置正確的日志級別)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM