azureloggingazure-functionsazure-application-insights

Azure function verbose trace logging to Application Insights


I have an Azure function that's connected to an App Insights instance. The function app emits log messages which I can see in the log stream in the Azure portal, and as App Insights traces.

I've increased the console log level to Verbose by adding a "tracing" element to host.json (https://github.com/Azure/azure-webjobs-sdk-script/wiki/host.json), so Verbose level messages show up in the log stream (in both the function page in the Azure portal, and in Kudu), but I can't get Verbose level traces to appear in App Insights.

Does anyone know how to get App Insights to show Verbose level traces from an Azure Function? Is it even possible? (Info traces and above are showing up just fine in App Insights)


Solution

  • You have a lot of control over your log levels for App Insights in Functions, but you don't use the tracing element for these. We're working on pulling the docs together in one cohesive location, but here's some links that can help:

    For your specific example, you can open up all the Debug logs (which matches Verbose in TraceWriter) with this in your host.json:

    {
      "logger": {
        "categoryFilter": {
          "defaultLevel": "Debug"     
        }
      }
    }
    

    If you just want to see the verbose logs coming from your Function itself (i.e. you don't want the host's verbose logs appearing), you can restrict that with this -- which says 'for logs with the "Function" category (which is the category that function logs use), show me everything with Debug or higher log level':

    {
      "logger": {
        "categoryFilter": {
          "categoryLevels": {
            "Function": "Debug"
          }
        }
      }
    }