Logging Azure函数在调试中记录消息

Logging Azure函数在调试中记录消息,logging,azure-functions,Logging,Azure Functions,当我在本地调试一个函数应用程序时,我现在在控制台窗口中收到一系列日志消息 看起来是这样的: [2020-10-04T20:48:31.130] corehub-control-03: Lease renewal with token 23fb44c2-49e4-4e1f-9ff4-058612d66f1e succeeded [2020-10-04T20:48:31.134] corehub-control-01: Lease renewal with token 6260dfd6-4f26-4

当我在本地调试一个函数应用程序时,我现在在控制台窗口中收到一系列日志消息

看起来是这样的:

[2020-10-04T20:48:31.130] corehub-control-03: Lease renewal with token 23fb44c2-49e4-4e1f-9ff4-058612d66f1e succeeded
[2020-10-04T20:48:31.134] corehub-control-01: Lease renewal with token 6260dfd6-4f26-4c28-8104-d9aeb4e027a1 succeeded
[2020-10-04T20:48:31.317] corehub-control-02: Lease renewal with token f5d0840f-c96b-4931-91ac-657a9ebf6c2e succeeded
[2020-10-04T20:48:32.309] corehub-control-00: Lease renewal with token fa3a4e6a-9d0b-4c70-8613-b95e069dc1f0 failed
[2020-10-04T20:48:32.316] corehub-control-00: Lease renewal with token fa3a4e6a-9d0b-4c70-8613-b95e069dc1f0 failed: Exception of type 'DurableTask.AzureStorage.Partitioning.LeaseLostException' was thrown.
[2020-10-04T20:48:32.328] corehub-control-00: SOLO is no longer processing messages for this partition
[2020-10-04T20:48:32.341] corehub-control-00: Stopped listening for messages on queue corehub-control-00.
[2020-10-04T20:48:32.351] corehub-control-00: Successfully acquired lease
[2020-10-04T20:48:32.371] corehub-control-01: Attempting to acquire lease
[2020-10-04T20:48:32.513] corehub-control-01: Successfully acquired lease
[2020-10-04T20:48:32.518] corehub-control-02: Attempting to acquire lease
[2020-10-04T20:48:32.641] corehub-control-02: Successfully acquired lease
[2020-10-04T20:48:32.647] corehub-control-03: Attempting to acquire lease
[2020-10-04T20:48:32.771] corehub-control-03: Successfully acquired lease
{
    "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingExcludedTypes": "Request",
      "samplingSettings": {
        "isEnabled": true
      }
    },
    "logLevel": {
      "Function": "Error",
    }
  }
}
失败和错误都很正常,但租约获取和续订消息似乎非常嘈杂。我在噪音中无法阅读自己的调试消息,并且随着应用程序继续运行,它会不断滚动

有没有办法把这些关掉?我尝试了很多设置,但它仍然看起来很健谈


TIA

您可以在host.json中添加节来过滤日志

例如,如果您只想看到错误,那么host.json应该如下所示:

[2020-10-04T20:48:31.130] corehub-control-03: Lease renewal with token 23fb44c2-49e4-4e1f-9ff4-058612d66f1e succeeded
[2020-10-04T20:48:31.134] corehub-control-01: Lease renewal with token 6260dfd6-4f26-4c28-8104-d9aeb4e027a1 succeeded
[2020-10-04T20:48:31.317] corehub-control-02: Lease renewal with token f5d0840f-c96b-4931-91ac-657a9ebf6c2e succeeded
[2020-10-04T20:48:32.309] corehub-control-00: Lease renewal with token fa3a4e6a-9d0b-4c70-8613-b95e069dc1f0 failed
[2020-10-04T20:48:32.316] corehub-control-00: Lease renewal with token fa3a4e6a-9d0b-4c70-8613-b95e069dc1f0 failed: Exception of type 'DurableTask.AzureStorage.Partitioning.LeaseLostException' was thrown.
[2020-10-04T20:48:32.328] corehub-control-00: SOLO is no longer processing messages for this partition
[2020-10-04T20:48:32.341] corehub-control-00: Stopped listening for messages on queue corehub-control-00.
[2020-10-04T20:48:32.351] corehub-control-00: Successfully acquired lease
[2020-10-04T20:48:32.371] corehub-control-01: Attempting to acquire lease
[2020-10-04T20:48:32.513] corehub-control-01: Successfully acquired lease
[2020-10-04T20:48:32.518] corehub-control-02: Attempting to acquire lease
[2020-10-04T20:48:32.641] corehub-control-02: Successfully acquired lease
[2020-10-04T20:48:32.647] corehub-control-03: Attempting to acquire lease
[2020-10-04T20:48:32.771] corehub-control-03: Successfully acquired lease
{
    "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingExcludedTypes": "Request",
      "samplingSettings": {
        "isEnabled": true
      }
    },
    "logLevel": {
      "Function": "Error",
    }
  }
}
检查功能应用程序的过滤器和日志级别:


谢谢您找到它。我找错地方了。事实证明,日志记录的事情可能真的很混乱。