gpt4 book ai didi

本地运行的 Azure Functions -- 无法从 'verbose' 设置日志记录级别控制台充满了垃圾

转载 作者:行者123 更新时间:2023-12-04 10:45:20 24 4
gpt4 key购买 nike

github 上似乎有很多答案,stackoverflow 上也有一些答案,但它们都不再有效/工作了。我正在尝试开发一个 azure-functions 节点应用程序,并在本地运行它将使控制台充满大量无用的垃圾。我一直在尝试改变函数的日志记录级别,但没有成功,我已将它们添加到我的 function.json 和 host.json 以及 local.settings.json 中,但它们没有任何区别。

大多数地方告诉我将其添加到“host.json”,但 tsling 会在 bat 右侧抛出“host.json 中不允许的属性 x”,尽管如此,我还是忽略它并尝试。

我已经尝试过:

{
"logger": {
"categoryFilter": {
"defaultLevel": "Information",
"categoryLevels": {
"Host.Results": "Error",
"Function": "Error",
"Host.Aggregator": "Information"
}
},
"aggregator": {
"batchSize": 1000,
"flushTimeout": "00:00:30"
}
},
"applicationInsights": {
"sampling": {
"isEnabled": true,
"maxTelemetryItemsPerSecond" : 5
}
}
}

也只有“错误”,但没有运气。

有人提到尝试:

{
"logger": {
"categoryFilter": {
"categoryLevels": {
"Function": "Error"
}
}
}
}

这也没有什么区别。

此外,这是淹没相关日志的无用垃圾的一小部分示例:

[Azure] [1/14/2020 10:17:57 AM] FunctionResultAggregatorOptions
[Azure] [1/14/2020 10:17:57 AM] {
[Azure] [1/14/2020 10:17:57 AM] "BatchSize": 1000,
[Azure] [1/14/2020 10:17:57 AM] "FlushTimeout": "00:00:30",
[Azure] [1/14/2020 10:17:57 AM] "IsEnabled": true
[Azure] [1/14/2020 10:17:57 AM] }
[Azure] [1/14/2020 10:17:57 AM] SingletonOptions
[Azure] [1/14/2020 10:17:57 AM] {
[Azure] [1/14/2020 10:17:57 AM] "LockPeriod": "00:00:15",
[Azure] [1/14/2020 10:17:57 AM] "ListenerLockPeriod": "00:00:15",
[Azure] [1/14/2020 10:17:57 AM] "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
[Azure] [1/14/2020 10:17:57 AM] "LockAcquisitionPollingInterval": "00:00:05",
[Azure] [1/14/2020 10:17:57 AM] "ListenerLockRecoveryPollingInterval": "00:01:00"
[Azure] [1/14/2020 10:17:57 AM] }
[Azure] [1/14/2020 10:17:57 AM] HttpOptions
[Azure] [1/14/2020 10:17:57 AM] {
[Azure] [1/14/2020 10:17:57 AM] "DynamicThrottlesEnabled": false,
[Azure] [1/14/2020 10:17:57 AM] "MaxConcurrentRequests": -1,
[Azure] [1/14/2020 10:17:57 AM] "MaxOutstandingRequests": -1,
[Azure] [1/14/2020 10:17:57 AM] "RoutePrefix": "api"
[Azure] [1/14/2020 10:17:57 AM] }

@Ian 的解决方案有效,但仍然出现一些轻微的垃圾,例如:

[Azure] [1/14/2020 1:03:47 PM] Restarting host.
[Azure] [1/14/2020 1:03:47 PM] Building host: startup suppressed: 'False', configuration suppressed: 'False', startup operation id: '04179110-ad25-4372-818c-b1c4f4a0e1ca'
[Azure] [1/14/2020 1:03:47 PM] Reading host configuration file 'C:\01 WORK\00 TLABS SOFTWARE\node-functions\host.json'
[Azure] [1/14/2020 1:03:47 PM] Host configuration file read:
[Azure] [1/14/2020 1:03:47 PM] {
[Azure] [1/14/2020 1:03:47 PM] "version": "2.0",
[Azure] [1/14/2020 1:03:47 PM] "logging": {
[Azure] [1/14/2020 1:03:47 PM] "fileLoggingMode": "never",
[Azure] [1/14/2020 1:03:47 PM] "logLevel": {
[Azure] [1/14/2020 1:03:47 PM] "Function.MyFunction": "None",
[Azure] [1/14/2020 1:03:47 PM] "default": "None"
[Azure] [1/14/2020 1:03:47 PM] },
[Azure] [1/14/2020 1:03:47 PM] "console": {
[Azure] [1/14/2020 1:03:47 PM] "isEnabled": "false"
[Azure] [1/14/2020 1:03:47 PM] }
[Azure] [1/14/2020 1:03:47 PM] }
[Azure] [1/14/2020 1:03:47 PM] }
[Azure] [1/14/2020 1:03:47 PM] Reading functions metadata
[Azure] [1/14/2020 1:03:47 PM] 1 functions found

还有几行。

如果能够变得更瘦就好了,但如果不是的话,那也很好。

最佳答案

您似乎正在将 Azure Functions 1.0 格式的配置文件与 Azure Functions 2.0 主机一起使用。请参阅 AF 2.0 配置文件架构的文档:https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json#logging

关于本地运行的 Azure Functions -- 无法从 'verbose' 设置日志记录级别控制台充满了垃圾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59731737/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com