In Azure Functions you use host.json to configure logging. However, the logging options/sections are unclear to me. Can someone help?
Per this: https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json
"logging": {
// FILE CONFIG?
"fileLoggingMode": "debugOnly"
"logLevel": {
"Function.MyFunction": "Information", // where is this log?
"default": "None"
},
// INSIGHTS CONFIG
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes" : "Dependency;Event",
"includedTypes" : "PageView;Trace"
},
Is the FILE CONFIG section used for logging in "log stream"? or is the INSIGHT section?
What is 'default' vs 'Function" log level?
I assume Filesystem logs is what controlled via FILE CONFIG section, correct?
FileLoggingMode
is used to generate the logs in azure portal or in a local Environment. The different modes in “fileLoggingMode”
are“debugOnly”: This level will generate logs when the function app is running on Azure Portal. This is the default mode.
“always”: This mode is used to generate logs in local environment as well as when running on Azure Portal. This code reference can be helpful to understand it better.
“never”: This mode does not generate any logs.
When the “fileLoggingMode”
is set to “always” the log file generated when running in local environment is stored in “C:\Users{user}\AppData\Local\Temp\LogFiles\Application\Functions\Function{Function_Name}”,
the path can be referenced here in the Host Settings code. If you are running the function app as docker/container in your local premises you can change the path by updating the host configuration code.
The fileLoggingMode
is still in issue see here
In a logging loglevel we have Parameters default/function/…
we where mention the Which type of log can we need to get like (error, information, trace, ….)
{
"logging": {
"fileLoggingMode": "always",
"logLevel": {
"default": "Information",
"Function": "Error"
}
}
}
Refer: Configure monitoring for Azure Functions | Microsoft Docs
(host.json).
If you are using "default": "Error"
you will get the Error logs by default.If you are using below configuration by default it will get the Information Log
and Funcition get the Error log
.
"default": "Information",
"Function": "Error"