In azure functions 3 can I filter logs to application insights and the console at different levels

Viewed 322

I'm developing azure functions using visual studio and the v3 runtime.

I'm trying to reduce the volume of trace messages going to application insights but I would still like to see them when running the function locally in visual studio.

From reading bits of documentation I think I need to set up log filtering at "Information" for the application insights provider and "Trace" for the console provider.

Is this possible? I've been trying out changing the hosts.json file from settings that I've found online but the filters only seem to apply to the log category, not the provider.

Is this possible?

1 Answers

You can override settings in your hosts.json file by creating an application setting. As per the docs, you just need a setting with a name like AzureFunctionsJobHost__path__to__setting. For example:

{
    "IsEncrypted": false,
    "Values": {
        /* snip */
        "AzureFunctionsJobHost__logging__logLevel__default": "Trace"
    }
}

And in your function app, just add AzureFunctionsJobHost__logging__logLevel__default with a value of Information.

Related