Azure Functions CLI - such a pretty logo for such an awesome functionality

How to enable verbose logging for Azure Functions?

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

  1. You’ll need to add this to the host.json file:

    <pre lang="xml">{
      ...
      "tracing":
      {
       "consoleLevel": "verbose"
      }
    }
    </pre>

  2. 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

  3. 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

  4. 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.
    host.json file location in Azure Functions app using ftp.

  5. 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
    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.

Remember to restart your (Function) app service after changing the host.json file - otherwise your changes won't get applied until it restarts automatically!
Remember to restart your (Function) app service after changing the host.json file – otherwise, your changes won’t get applied until it restarts automatically!

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:

How to find host.json in your Visual Studio solution
How to find host.json in your Visual Studio solution

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?
OffNothing at all!
Errorerror-handling messages
WarningWarnings & errors
InfoInfo, warnings, errors
VerboseAll logging – when tracking an error, you probably wnat this.

Sources:

mm
0 0 votes
Article Rating
Subscribe
Notify of
guest

6 Comments
most voted
newest oldest
Inline Feedbacks
View all comments