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

如何解决Azure Function的App Insights日志泛滥,仅保留自定义日志?

Azure Functions 冗余日志禁用问题

我正尝试禁用Azure平台上已部署的Azure Function中的冗余日志。本地运行时只显示自定义的Information级日志,但在Azure App Insights日志流里,大量日志(比如Requests、Responses、DbCommands以及“Executing function (Reason=)”这类)几秒内就会填满控制台。这些日志在本地通过host.json已经能禁用,但部署到Azure环境后依然会显示。

我已经试过以下操作:

  • 在host.json中把logLevel的"default"和"Function"都设为"Warning"
  • 在applicationInsights.samplingSettings里设置maxTelemetryItemsPerSecond为0
  • 在applicationInsights.samplingSettings中配置excludedTypes参数
  • 通过Startup.cs禁用遥测日志

但以上方法都没用,冗余日志还是大量出现。我希望只显示自己写的Information级日志,其他日志至少要达到Warning级别或者直接不显示。我的host.json内容如下:

{
  "version": "2.0",
  "logging": {
    "logLevel": {
      "default": "Warning",
      "RestApiFunctions.Functions": "Information",
      "RestApiFunctions.SignalR": "Information",
      "DataLayer": "Information",
      "ServiceLayer": "Information",
      "Function": "Warning"
    },
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Trace;Request"
      },
      "LogLevel": {
        "Default": "Warning"
      }
    }
  },
  "openApi": {
    "info": {
      "version": "1.0.0",
      "title": "INEX Cloud REST API"
    }
  },
  "extensions": {
    "http": {
      "customHeaders": {
        "Access-Control-Expose-Headers": "X-Total-Count"
      }
    }
  }
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.05 02:20:14