Azure功能在调试中记录消息

时间:2020-10-04 20:52:36

标签: 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-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

失败和错误很好,但是租约获取和续订消息似乎很嘈杂。我在读取自己的调试消息时遇到了麻烦,随着应用程序继续运行,它会不断滚动。

有什么办法可以关闭它们?我已经尝试了许多设置,但看起来还是很健谈。

TIA

1 个答案:

答案 0 :(得分:1)

您可以在host.json中添加部分以过滤日志。

例如,如果您只想查看错误,则host.json应如下所示:

{
    "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingExcludedTypes": "Request",
      "samplingSettings": {
        "isEnabled": true
      }
    },
    "logLevel": {
      "Function": "Error",
    }
  }
}

检查过滤器和功能应用程序的日志级别:

https://docs.microsoft.com/en-us/azure/azure-functions/functions-monitoring?tabs=cmd#log-levels