There seems to be a ton of answers out there on github and a few here on stackoverflow but none of them are valid/work anymore. I'm trying to develop an azure-functions node app and running it locally will fill up the console with a ton of useless garbage. I've been trying to alter the logging level of the function to no avail, I've added these both to my function.json and host.json and local.settings.json but they haven't made any difference.
Most places tell me to add it to 'host.json' but tsling throws right of the bat that 'property x not allowed in host.json', nonetheless I ignore it and try anyway.
I've tried:
{
"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
}
}
}
With just 'Errors' as well but no luck.
Someone has mentioned trying:
{
"logger": {
"categoryFilter": {
"categoryLevels": {
"Function": "Error"
}
}
}
}
This does not make a difference either.
Also, here's a small sample of the useless garbage drowning out relevant logs:
[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's solution works but still getting some minor level of garbage, such as:
[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
and a few more lines.
Would be nice to be able to go even leaner but if not it's still good.
It seems like you're using an Azure Functions 1.0-format configuration file with an Azure Functions 2.0 host. Please refer to the documentation for the AF 2.0 configuration file schema: https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json#logging