Reputation: 95
I'm curious if there's a way for overriding the loglevel of the azure function default or built-in logs.
I've attached a screenshot below with some examples of the unwanted logs.
I've found out that I can override the setting for my custom logs in app.settings by adding this: AzureFunctionsJobHost__logging__LogLevel__Default
Is there a way to differentiate my custom logs from the default logging?
Stop an Azure Function from logging the “Executing” and “Executed” messages
I went through this post, but I noticed people complaining about their custom information logs not being logged into app insights anymore.
Also, I've read some Microsoft documentation about a settings AzureWebJobsDashboard that you should delete if you want to disable built-in logging. However, I can't find this setting in the azure function app.settings.
I would highly appreciate if someone would clarify this topic for me, I'm kind of a junior with Azure. Also sorry if this post is spam.
Thank you for your time! :D
Upvotes: 3
Views: 4818
Reputation: 470
This is the same issue as can be found here:How to disable durable function verbose logging
Is there a way to differentiate my custom logs from the default logging? Yes there is
A way to disable the logs of AzureFunctions but not your own logging can be found here: https://github.com/anthonychu/functions-log-suppression
You will have to disable the logging for Functions (or set to whatever Log level you want) and then add the log level for user logging for each function. There is apparently no way to set log level for all user logging so you will sadly need to do it for each function.
Here is an example given by the URL and I have run it locally and it worked for me. in local.stting.json:
{
"logging:logLevel:Microsoft": "None",
"logging:logLevel:Worker": "None",
"AzureFunctionsJobHost:logging:logLevel:default": "None",
"AzureFunctionsJobHost:logging:logLevel:Host.Function.Console": "Information",
"AzureFunctionsJobHost:logging:logLevel:Function.HttpTrigger1.User": "Information",
"AzureFunctionsJobHost:logging:logLevel:Function.HttpTrigger2.User": "Information"
}
Upvotes: 0
Reputation: 4786
Overriding the loglevel of the azure function default or built-in logs
Yes, we can override function log level after deployed into azure.
After deployed in azure if you want to override logging keep adding the AzureFunctionsJobHost__path__to__setting setting in Application Settings in function Configuration. If you added the settings in Application
Settings it will override into host.json
AzureFunctionsJobHost__path__to__setting
I have added in my function and the local.settings.json
. In Below default log level has information "default": "Information"
changing to Debug using "AzureFunctionsJobHost__logging__logLevel__Default": "Debug"
.
After deployment Use portal to override.
In host.json
while logging your function telemetry information we are using log levels and categories Ms-Doc. Use Log Level
has None
to disable the specified category log.
"logLevel": {
"default": "Information",
"Host.Results": "Error", // Host.Results will collect only Error
"Function": "None", // Disable logging for the Function catagory
"Host.Aggregator": "Trace"
}
Upvotes: 3