You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET 5 Isolated模式下Azure Functions Application Insights Trace事件过滤问询

调整方案

你需要针对四类冗余日志对应的日志源,补充调整host.json中的logLevel规则,将对应分类的日志级别提升至Warning即可屏蔽Information级别的冗余上报:

  • 第一类Posting invocation id:*** on workerId:***日志:你已经配置了对应Rpc调度类的级别,可补充覆盖整个Worker分类避免遗漏
  • 第二类、第三类函数执行启停日志:对应Azure Functions Host的执行统计分类,新增对应分类的级别限制即可
  • 第四类路由匹配日志:可补充Http触发器分类的级别限制,彻底屏蔽路由相关的Info日志

调整后的logLevel配置参考

"logLevel": {
    "Default": "Information",
    "***.***": "Information",
    "Host.Controllers.Host": "Warning",
    "Microsoft": "Warning",
    // 屏蔽Rpc调用相关的Info日志,对应第一类冗余日志
    "Microsoft.Azure.WebJobs.Script.Workers": "Warning",
    "Microsoft.Azure.WebJobs.Script.Description.WorkerFunctionInvoker": "Warning",
    "Microsoft.Azure.WebJobs": "Warning",
    // 屏蔽函数执行启停的Info日志,对应第二、三类冗余日志
    "Host.Results": "Warning",
    "Host.Function": "Warning",
    "Functions.***": "Information",
    // 屏蔽路由匹配相关的Info日志,对应第四类冗余日志
    "Microsoft.AspNetCore.Routing": "Warning",
    "Host.Triggers.Http": "Warning"
}

注意事项

  • .NET 5 Isolated模式的日志规则优先级是分类越精确优先级越高,如果你有个别函数需要保留执行日志,可以单独给Functions.具体函数名设置为Information即可,不会影响全局过滤规则
  • 原有你自己业务代码输出的Information级别的日志不受以上配置影响,可以正常上报到Application Insights

内容的提问来源于stack exchange,提问作者metase

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 21:06:04