This post was most recently updated on March 28th, 2023.
3 min read.This post describes how you can easily enable debug/verbose information for your Azure Functions for a lightweight and built-in way to extract just a bit more information out of your Azure Function executions.
There are different methods available for Azure and your local development environment.
Problem
Azure Functions are awesome. But by default, your tools for gathering information without some additional configuration are not that great. The “monitor” view of the function doesn’t give you more than an excerpt of the console.
This applies not only to the “production” Azure cloud environment, where the function invocation log is very concise, and even Kudu exposes very simple logging information. Additionally, this applies pretty much completely to your local development environment as well!
However, you can extract a bit more information by enabling verbose logging. Sometimes that might be just enough to get that additional tidbit of information, that’ll help you figure out the issue!
Solution
Okay – so it’s a minor improvement, but worth documenting. Changing your host.json file for your Azure Functions app (local or in Azure Functions app) allows you to enable verbose logging for your functions.
Solution for Azure:
Modify the host.json file in the cloud
- You’ll need to add this to the host.json file:
<pre lang="xml">{
...
"tracing":
{
"consoleLevel": "verbose"
}
}
</pre> - To do that, you’ll need to access the file system of your (Functions) app service. You can get there by following this path:
Azure Portal > Function Apps > [Your Function App] > Platform Features > Advanced Tools (Kudu) > Tools > PowerShell
- And then open the following directory:
<pre>site > wwwroot > host.json</pre>
Kind of a shorthand way would be to jump directly to this address:
https://[contosofunctionappsite].scm.azurewebsites.net/DebugConsole/?shell=powershell - Alternatively, you could also just use ftp to do that and navigate to the same folder- as shown below:
host.json file location in Azure Functions app using ftp. - Once you have the file open, no matter which way, make sure to update the file so that it contains the tracing level set to verbose.
<pre lang=”json”>{
“queues”: {
“maxPollingInterval”: 1000
},
“tracing”:
{
“consoleLevel”: “verbose”,
“fileLoggingMode”: “debugOnly”
}
}
</pre>
It should look something like the below:
TracingLevel set to verbose in host.json
Remember to restart your function app to apply the changes! Just saving the file is not enough, they won’t take action until the IIS instance behind the (function) app service is recycled.
Solution for the local environment: modify host.json in your solution
Okay – so this is very similar to what you need to do in Azure. Just instead of fishing out the host.json file from Azure, open it from Visual Studio:
And just like on Azure, you add this in the file:
{
...
"tracing":
{
"consoleLevel": "verbose"
}
}
And the next time you should have more logging!
References and additional information
Copy-pasting these here, so that I can finally close the browser tabs I have these open on.
Different logging levels:
Value | What it does? |
---|---|
Off | Nothing at all! |
Error | error-handling messages |
Warning | Warnings & errors |
Info | Info, warnings, errors |
Verbose | All logging – when tracking an error, you probably wnat this. |
Sources:
- “Performing cleanup” – Excel is stuck with an old, conflicted file and will never recover. - November 12, 2024
- How to add multiple app URIs for your Entra app registration? - November 5, 2024
- How to access Environment Secrets with GitHub Actions? - October 29, 2024