I have an Azure Function App which has Application Insights configured. My functions have some LogTrace()
messages in but they are not being captured by AppInsights. Do I have to configure a minimum loglevel somewhere?

- 29,865
- 2
- 44
- 60

- 1,938
- 4
- 23
- 33
3 Answers
Please take a look at this article on how to set log level for function v1 or v2.
In the file host.json
, for the filed "Function", set its value to Trace. Then LogTrace() can be logged into application insights.
Sample host.json
for Azure function v2, which can log trace messages to Application Insights:
{
"version": "2.0",
"logging": {
"fileLoggingMode": "always",
"logLevel": {
"default": "Information",
"Host.Results": "Error",
"Function": "Trace",
"Host.Aggregator": "Trace"
}
}
}
And if you publish your function app with visual studio, you can modify your host.json file as per the above before publishing.
And if you want to change the log level in azure portal, please follow this:
In Azure portal, navigate to your function app -> in the function app settings, make sure enable the Read/Write, then change log level to trace in the host.json
.

- 748
- 1
- 6
- 31

- 29,865
- 2
- 44
- 60
-
2Useful answer, thank you. May I ask, is it possible to control the log level for each function separately? The URL below suggests it is possible to specify Function.MyFunction - but I am unsure what MyFunction refers to here. Is this the name used in the "FunctionName" attribute in C# for example? https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json – cbailiss Apr 07 '19 at 18:06
-
@cbailiss, could you please post a new issue for this? – Ivan Glasenberg Apr 09 '19 at 00:32
I can't see any host.json file in azure portal but I could update it from application settings(environment variable). To replace default log level set key AzureFunctionsJobHost__logging__LogLevel__Default
and value Trace
/Debug
/Information
or whatever you want. Like for me in my host.json Default
is Trace
but in azure it is Information
. So just add new environment variable(Application settings) and prefix with AzureFunctionsJobHost__logging__LogLevel__
for all the keys of loglevel and set the desired value and your host settings will be overridden.
You can read more Here
-
THANK YOU! I have been going back and forth for days trying to figure out why i couldn't get my debug logs to show locally. This fixed it! And thank you for the link! – Casper Wilkes Oct 26 '22 at 13:35
To further add to @Ivan Yang's excellent answer, you can specify a minimum logging level per function in v2 of Azure Functions. (I have not verified if it does/doesn't work in v1) Using his example host.json
:
{
"version": "2.0",
"logging": {
"fileLoggingMode": "always",
"logLevel": {
"default": "Information",
"Host.Results": "Error",
"Function": "Trace",
"Function.FunctionA": "Warning",
"Host.Aggregator": "Trace"
}
}
}
Function.FunctionA
is assuming you have a function named (via the FunctionName
attribute) "FunctionA", e.g.:
[FunctionName("FunctionA")]
public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "")]HttpRequest req, ILogger log)
{
...function code here
}
So whatever value you specify in the FunctionName
attribute can be used to explicitly define a minimum log level just for that function. In the host.json
example above, all functions, by default, will have a minimum log level of Trace
while FunctionA will have a minimum log level of Warning
.

- 579
- 4
- 9
-
2Modifying a file to change log levels is not ideal - is there a way to do it via ENV variables or application configuration? – Karpik Mar 17 '20 at 03:16
-
@Karpik, I don't believe so. See https://stackoverflow.com/questions/60658607/overriding-log-level-for-azure-functions. – Blair Allen Mar 18 '20 at 12:12
-
4I've actually found it and it works! https://stackoverflow.com/questions/53405020/configure-loglevel-of-azure-function-using-environment-variables – Karpik Mar 21 '20 at 03:24