Azure函数表绑定(bind)产生大量日志记录噪音

标签 azure azure-functions

刚刚将 azure 函数从 v3 升级到 v4 和 dotnet6。注意到运行时绑定(bind)也需要更新。

我刚刚对其进行了测试,并注意到有很多详细的日志记录来自表绑定(bind)以及我自己的日志记录。我怎样才能排除这个?我应该排除它吗?当观察活原木时,很难从树上看到木材

[FunctionName("Function2")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            [Table("Keys", Connection = "TableStorage")] TableClient keysTable,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");
         
            if (keysTable != null)
            {
                try
                {
                    var item2 = keysTable.GetEntity<TableEntity>("jon", "test");  
                }
                catch (Exception)
                {
                    log.LogError("key not present");
                }
            }

            log.LogInformation("C# HTTP trigger function completed.");
            return new OkObjectResult(new { });
        }

日志输出

2022-12-28T12:40:14Z   [Information]   Request [6b093468-5e75-4e8c-b358-e47f0dffc632] POST https://xxx.table.core.windows.net/Tables?$format=REDACTED
x-ms-version:REDACTED
DataServiceVersion:REDACTED
Prefer:REDACTED
Accept:application/json; odata=minimalmetadata
x-ms-client-request-id:6b093468-5e75-4e8c-b358-e47f0dffc632
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Data.Tables/12.7.1,(.NET 6.0.11; Microsoft Windows 10.0.14393)
x-ms-date:REDACTED
Authorization:REDACTED
Content-Type:application/json; odata=nometadata
client assembly: Azure.Data.Tables
2022-12-28T12:40:14Z   [Information]   Response [6b093468-5e75-4e8c-b358-e47f0dffc632] 409 Conflict (00.0s)
Cache-Control:no-cache
Transfer-Encoding:chunked
Server:Windows-Azure-Table/1.0,Microsoft-HTTPAPI/2.0
x-ms-request-id:e63cd248-2002-0051-25b9-1ae043000000
x-ms-client-request-id:6b093468-5e75-4e8c-b358-e47f0dffc632
x-ms-version:REDACTED
X-Content-Type-Options:REDACTED
Preference-Applied:REDACTED
Date:Wed, 28 Dec 2022 12:40:13 GMT
Content-Type:application/json; odata=minimalmetadata; streaming=true; charset=utf-8
2022-12-28T12:40:14Z   [Information]   Executing 'Function2' (Reason='This function was programmatically called via the host APIs.', Id=3598edde-1658-414b-9cc4-481bb6f7810e)
2022-12-28T12:40:14Z   [Information]   C# HTTP trigger function processed a request.,

我原以为只会显示我的日志记录。

我已通读此内容并发现了这一 block 信息

https://learn.microsoft.com/en-us/azure/azure-functions/functions-monitoring#disable-built-in-logging

Dependencies Starting with version 2.x of Functions, Application Insights automatically collects data on dependencies for bindings that use certain client SDKs. Application Insights distributed tracing and dependency tracking aren't currently supported for C# apps running in an isolated worker process. Application Insights collects data on the following dependencies:

Azure Cosmos DB
Azure Event Hubs
Azure Service Bus
Azure Storage services (Blob, Queue, and Table)

没有说明如何禁用它

Host.json 文件

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  }
}

最佳答案

更新 host.json 文件以仅包含这些类别的错误日志对我有用。

{
  "version": "2.0",
  "logging": {
    "logLevel": {
      "default": "Information",
      "Azure.Core": "Error",
      "Azure.Messaging.ServiceBus": "Error"
      //others categories you have noise
    }
  }
}

关于Azure函数表绑定(bind)产生大量日志记录噪音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74940378/

相关文章:

Azure Python Sdk 列出订阅中的所有 Web 应用程序

azure - VM 仍然产生计算费用,即使它是 "stopped"?

azure - 使用 HTTP 触发器/通用 Webhooks 创建 Azure 函数之间的区别?

javascript - azure函数不在本地运行

c# - Azure 服务总线和 Azure 函数队列触发器

azure - 应用洞察 : How to query full trace of azure function executions containing errors?

powershell - 在新的 Azure VM 上启用 PowerShell 远程处理

azure - 为什么在部署 Blazor 服务器端应用程序时建议使用 Azure SignalR 服务?

azure - 使用 Azure CLI 重新启动 Azure 云服务实例

node.js - 如何从 Nodejs 中的同步 Azure 函数返回结果