How to stop info and debug messages from Azure function host

Stanley Yau 0 Reputation points
2024-06-20T20:41:49.0966667+00:00

The Azure function infrastructure spits out a lot of info and debug messages which I want to filter out. Log level filtering seems to be specific to Application Insights which if disabled for my function app.

e.g.

Starting JobHost

Starting Host (HostId ...

FUNCTIONS_WORKER_RUNTIME value: 'dotnet-isolated'

Adding Function descriptor provider for language dotnet-isolated.

...

Poll for function ...

Function 'xxxx' will wait 335.6767 ms before polling queue ...

Executing HTTP request: { "requestId": "623275a0-e13e-41ff-9dc0-e6020fa01538", "method": "GET", "userAgent": "HealthCheck/1.0...

...

I tried the following in host.json.

"logging": {

    "logLevel": {

        "default": "None",

        "Function": "Error",

        "Function.Myfunction": "Error",

        "Function.Myfunction.User": "Error",

        "Azure.Core": "Warning",

        "Azure.Storage.Blobs": "Error",

        "Azure.Storage.Queues": "Error",

        "Host.Aggregator": "Error",

        "Host.Results": "Error"

    }

},

The function uses Serilog. Tried the following settings.

"Serilog": {

    "MinimumLevel": {

        "Default": "Error",

        "Override": {

            "Microsoft": "Error",

            "System": "Error",

            "MicroElements": "Error",

            "Microsoft.EntityFrameworkCore": "Error",

            "Zenfolio.Common.EntityFramework": "Error",

            "Azure": "Warning",

            "Azure.Core": "Warning",

            "Azure.Storage.Blobs": "Warning",

            "Azure.Storage.Files": "Warning",

            "Azure.Storage.Queues": "Warning",

            "Microsoft.Azure.Functions.Worker.Extensions.Storage": "Warning",

            "Microsoft.Azure.Functions.Worker": "Warning",

            "Microsoft.Extensions.Azure": "Warning",

            "Microsoft.Extensions.Configuration": "Warning",

            "Microsoft.Azure.WebJobs.Extensions.Storage.Blobs": "Warning",

            "Microsoft.Azure.WebJobs.Extensions.Storage": "Warning"

        }

    },

    "WriteTo": []

},

None of the log level settings in host.json and Serilog work.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,614 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pinaki Ghatak 3,035 Reputation points Microsoft Employee
    2024-06-21T10:05:17.0333333+00:00

    Hello @Stanley Yau

    Here are a few suggestions that might help:

    1. Set a higher log level: The execution logs you want to get rid of are generated by the function runtime. You can set a higher log level to filter information and keep your self-defined info. For example, in your host.json, you can set the log level for Function and Function.MyFunctionName.User to Error
    2. Use Azure portal to override: After deploying in Azure, if you want to override logging, you can add the AzureFunctionsJobHost__path__to__setting setting in Application Settings in the function Configuration.
    3. Disable specific function logging: In host.json, while logging your function telemetry information, you can use the log level None to disable the specified category log
    4. Disable built-in logging: If you want to disable built-in logging, you can delete the AzureWebJobsDashboard app setting

    Please note that these changes might affect your custom information logs.


    I hope that this response has addressed your query and helped you overcome your challenges. If so, please mark this response as Answered. This will not only acknowledge our efforts, but also assist other community members who may be looking for similar solutions.