为 Azure Functions 配置日志级别 [英] Configuring Log Level for Azure Functions

查看:17
本文介绍了为 Azure Functions 配置日志级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个配置了 Application Insights 的 Azure Function App.我的函数中有一些 LogTrace() 消息,但它们没有被 AppInsights 捕获.我必须在某处配置最低日志级别吗?

解决方案

请看这个

I have an Azure Function App which has Application Insights configured. My functions have some LogTrace() messages in but they are not being captured by AppInsights. Do I have to configure a minimum loglevel somewhere?

解决方案

Please take a look at this article on how to set log level for function v1 or v2.

In the file host.json, for the filed "Function", set its value to Trace. Then LogTrace() can be logged into application insights.

Sample host.json for Azure function v2, which can log trace messages to Application Insights:

{
  "version": "2.0",
  "logging": {
    "fileLoggingMode": "always",
    "logLevel": {
      "default": "Information",
      "Host.Results": "Error",
      "Function": "Trace",
      "Host.Aggregator": "Trace"
    }
  }
}

And if you publish your function app with visual studio, you can modify your host.json file as per the above before publishing.

And if you want to change the log level in azure portal, please follow this:

In Azure portal, navigate to your function app -> in the function app settings, make sure enable the Read/Write, then change log level to trace in the host.json.

这篇关于为 Azure Functions 配置日志级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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