Azure 函数详细跟踪日志记录到 Application Insights [英] Azure function verbose trace logging to Application Insights

查看:21
本文介绍了Azure 函数详细跟踪日志记录到 Application Insights的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个连接到 App Insights 实例的 Azure 函数.函数应用发出日志消息,我可以在 Azure 门户的日志流中看到这些消息,并作为 App Insights 跟踪.

I have an Azure function that's connected to an App Insights instance. The function app emits log messages which I can see in the log stream in the Azure portal, and as App Insights traces.

我通过将 "tracing" 元素添加到 host.json (https://github.com/Azure/azure-webjobs-sdk-script/wiki/host.json),因此详细级别的消息会显示在日志流中(在 Azure 门户的功能页面和 Kudu 中),但我无法让详细级别的跟踪显示在 App Insights 中.

I've increased the console log level to Verbose by adding a "tracing" element to host.json (https://github.com/Azure/azure-webjobs-sdk-script/wiki/host.json), so Verbose level messages show up in the log stream (in both the function page in the Azure portal, and in Kudu), but I can't get Verbose level traces to appear in App Insights.

有谁知道如何让 App Insights 显示来自 Azure 函数的详细级别跟踪?甚至可能吗?(信息跟踪及以上在 App Insights 中显示得很好)

Does anyone know how to get App Insights to show Verbose level traces from an Azure Function? Is it even possible? (Info traces and above are showing up just fine in App Insights)

推荐答案

您可以对 App Insights in Functions 的日志级别进行大量控制,但您不使用 tracing 元素这些.我们正在努力将文档集中到一个有凝聚力的位置,但这里有一些链接可以提供帮助:

You have a lot of control over your log levels for App Insights in Functions, but you don't use the tracing element for these. We're working on pulling the docs together in one cohesive location, but here's some links that can help:

  • The new logger.categoryLevel host.json settings: https://github.com/Azure/Azure-Functions/wiki/App-Insights-(Preview)#hostjson-settings
  • The WebJobs documentation, which gives a bit more detail on how the category filter works (behind the scenes, the host.json settings are serialized into this): https://github.com/Azure/azure-webjobs-sdk/wiki/Application-Insights-Integration#filtering

对于您的具体示例,您可以在主机中打开所有 Debug 日志(与 TraceWriter 中的 Verbose 匹配).json:

For your specific example, you can open up all the Debug logs (which matches Verbose in TraceWriter) with this in your host.json:

{
  "logger": {
    "categoryFilter": {
      "defaultLevel": "Debug"     
    }
  }
}

如果您只想查看来自您的函数本身的详细日志(即您不希望出现主机的详细日志),您可以使用它来限制它——它表示对于具有函数"类别的日志(这是函数日志使用的类别),显示所有带有 Debug 或更高日志级别的内容:

If you just want to see the verbose logs coming from your Function itself (i.e. you don't want the host's verbose logs appearing), you can restrict that with this -- which says 'for logs with the "Function" category (which is the category that function logs use), show me everything with Debug or higher log level':

{
  "logger": {
    "categoryFilter": {
      "categoryLevels": {
        "Function": "Debug"
      }
    }
  }
}

这篇关于Azure 函数详细跟踪日志记录到 Application Insights的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆