When my Azure Function is triggered, it logs “Executing” and “Executed” messages. This is fine during testing but as this Function gets triggered a lot, it is creating a lot of unwanted log messages. The logging that I have added myself is important to me but I would like to disable the Function's own “Executing” and “Executed” messages. To clarify, it is the following messages I don’t want logged:
Executing ‘MyFunctionName’ (Reason='New ServiceBus message detected……etc’)
Executed ‘MyFunctionName’ (Succeeded, Id=a99c6932-788f-439e-a7db-aad7f607d5ea)
The execution logs you want to get rid of is generated by function runtime, we can set a higher log level to filter information and keep our self-defined info.
Go to Azure portal, Platform features> Function app settings> host.json
For Function app v2, with this setting in host.json, the logs excluded are nowhere to find.
{
"version": "2.0",
"logging": {
"logLevel": {
"Function.MyFunctionName.User": "Information",
"Function": "Error"
}
}
}
For v1, use ILogger instead of TraceWriter. This setting in host.json only restricts those sent to Application Insights, which means we can still see them in console or file logs.
{
"logger": {
"categoryFilter": {
"categoryLevels": {
"Host.Executor": "Error"
}
}
}
}
To disable built-in logging, delete the AzureWebJobsDashboard app setting.
Source: Monitor Azure Functions - Disable built-in logging
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With