Azure函数在调试中记录消息



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

它看起来像这样:

[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-

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

例如,如果你只想看到错误,你的host.json应该是这样的:

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

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

https://learn.microsoft.com/en-us/azure/azure-functions/functions-monitoring?tabs=cmd#log-水平

最新更新