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

Azure Functions running locally -- cannot set logging level from 'verbose' console is full of garbage

github 上似乎有大量答案,Whosebug 上也有一些答案,但 none 不再是 valid/work。我正在尝试开发一个 azure-functions 节点应用程序,运行 它在本地会用大量无用的垃圾填满控制台。我一直在尝试更改函数的日志记录级别但无济于事,我已将这些都添加到我的 function.json 和 host.json 以及 local.settings.json 但它们没有任何区别.

大多数地方都告诉我将它添加到 'host.json',但 tsling 抛出 'property x not allowed in host.json' 的正确方法,none尽管如此,我还是忽略了它并尝试了。

我试过:

{
  "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
    }
  }
}

也只有 'Errors',但运气不好。

有人提到尝试:

{
  "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: WORK[=15=] 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://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json#logging