Azure Function Logging

There's a few resources out there about customizing the logging of Azure Functions... but none worked for me.

I mean, one worked. This blog post. Even it doesn't SPECIFY the setting, just assumes it'll be inferred.

Well... I did. But I'm going to put here how to customize the logging for an azure function.

If you go tot the docs for host.json it provides the following snippet

"logging": {
    "fileLoggingMode": "debugOnly",
    "logLevel": {
      "Function.MyFunction": "Information",
      "default": "None"
    },
    "console": {
        ...
    },
    "applicationInsights": {
        ...
    }
}

and is just "yep, 'Function.MyFunction' - Have Fun!". I had NO idea what the hell that meant.

The above linked function clarified it for me, but let me call it out here.

In the logLevel node, the Function.MyFunction is the FULLY QUALIFIED DOMAIN NAME for the CLASS that has the function.

If my function is defined as

namspace Quinn.Gets.Annoyed;

public class WithAzureFunctions
{
...
}

Then the logLevel node will look like

"logging": {
    "fileLoggingMode": "debugOnly",
    "logLevel": {
      "Quinn.Gets.Annoyed.WithAzureFunctions": "Information",
      "default": "None"
    },
    "console": {
        ...
    },
    "applicationInsights": {
        ...
    }
}

So, there ya go.

Customize individual Azure Function logging with the logging logLevel node.

The docs could be better.

Show Comments