Azure / azure-functions-core-tools

Command line tools for Azure Functions
MIT License
1.3k stars 430 forks source link

Cannot disable trigger logging #3424

Open mlowijs opened 1 year ago

mlowijs commented 1 year ago

Hi there,

I'm trying to disable all logging below Warning level in my Azure Functions (isolated, .NET 7) The logging I'm trying to disable is from the Azure.Messaging.EventHubs and Azure.Messaging.ServiceBus categories, for which I have triggers in my Function app. An example of log rules:

Completed receiving events for Event Hub: xxx (Consumer Group: 'yyy', Partition Id: '8'); Operation Id: '7d27c6b8-b909-44a0-a98c-7fc9ad8d498c'. Service Retry Count: 0; Event Count: 0; Duration: '60.01' seconds

xxx/Subscriptions/yyy-93337300-67c8-4c69-ba48-570f7a5dd732-S128: RenewSessionLockAsync start. SessionId = 128

I've setup my code like this:

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults(builder =>
    {
        builder
            .AddApplicationInsights()
            .AddApplicationInsightsLogger();
    })
    .ConfigureLogging(builder =>
    {
        builder.SetMinimumLevel(LogLevel.Error);

        builder.AddFilter("Azure.Messaging.EventHubs", LogLevel.Error);
        builder.AddFilter("Azure.Messaging.ServiceBus", LogLevel.Error);
    })

And my host.json like this:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    },
    "fileLoggingMode": "debugOnly",
    "logLevel": {
      "default": "Error",
      "Host.Results": "Error",
      "Function": "Error",
      "Host.Aggregator": "Trace",
      "Azure.Messaging.EventHubs": "Error",
      "Azure.Messaging.ServiceBus": "Error"
    }
  }
}

But the log rules below the Error level still come through.

How can I do this properly?

01F0 commented 1 year ago

I have the same problem (isolated, .NET 7), more specifically when viewing logs in Log stream: