gpt4 book ai didi

c# - 使用 Azure Log Analytics 在 Azure Function v3 中进行结构化日志记录

转载 作者:行者123 更新时间:2023-12-03 00:01:53 27 4
gpt4 key购买 nike

我尝试通过登录我的 Azure 函数来使用结构化日志记录,如下所示:

log.LogError("Failed to get object. ({customerId}, {objectId}, {errorMessage})", request.CustomerId,
request.ObjectId, errorMessage);

我的 Azure Function 已通过诊断设置插入 Log Analytics 工作区。

有没有办法从消息中提取 customerId、objectId 和 errorMessage ?

我想创建一个仪表板,显示每个 customerId 的错误数。

我尝试过“提取字段”功能,但没有成功。我需要使用 Application Insights 和自定义维度吗?

最佳答案

您几乎已经走在正确的道路上了。通过上面共享的示例日志语句,如果您启用了内置 App Insights Integration,您应该已经在 Application Insights 日志的 customDimentions 中看到 customerId、objectId、errorMessage。 。这就是确切的原因,Loging in .net core是以这种方式构建的模板。您还可以在 Azure Function structured logging 中找到详细信息。 enter image description here

但是您提到您正在通过诊断设置使用 Log Analytics 工作区,我认为该设置尚不支持结构化日志记录(目前处于预览状态,因此将来可能会发生变化)。 enter image description here

因此,Application Insights 将是您的最佳选择。除了 App Insights 的内置查询 Pane 之外,您还可以从 Log Analytics 查询应用程序见解。

关于c# - 使用 Azure Log Analytics 在 Azure Function v3 中进行结构化日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63743853/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com