【问题标题】:How can I reduce the number of logs generated by Azure Blob Storage如何减少 Azure Blob Storage 生成的日志数量
【发布时间】:2023-01-16 12:17:54
【问题描述】:

在 Azure Functions 中,我希望能够仅记录来自 Azure.Storage.Blobs 的警告和异常,但我仍然需要我的代码中的所有痕迹。有没有办法限制 Azure.Storage.Blobs 记录的日志级别?

我尝试将 Blob 添加到 host.json 中,但这似乎没有任何影响。

    "logLevel": {
      "default": "Information",
      "Azure.Storage.Blobs": "Warning"
    }

【问题讨论】:

    标签: azure-functions azure-blob-storage


    【解决方案1】:

    要记录警告、来自 NuGet 包 Azure.Storage.Blobs 的异常和来自函数代码的跟踪,host.json 的配置有助于获取它们:

    {
      "version": "2.0",
      "logging": {
        "applicationInsights": {
                "samplingSettings": {
                    "isEnabled": true,
                    "excludedTypes": "Request"
                }
            },
        "fileLoggingMode": "always",
        "logLevel": {
          "default": "Information",
          "Host.Results": "Error",
          "Function": "Trace",
          "Host.Aggregator": "Trace",
          "Azure": "Information",
          "Azure.Storage.Blobs": "Warning",
          
        }
      }
    }
    

    此处 Function 设置为 Trace,因此可以在 Application Insights 资源中捕获 LogTrace() 方法。

    要获取警告级别日志,日志级别属性应包含 Warning 或高于 Warning 的值,例如 InformationTrace/VerboseDebug

    注意:以上配置代码片段取自参考文献 MS Doc1 & Doc2

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-15
      • 2020-07-15
      相关资源
      最近更新 更多