2

We've moved from Net6 in-process to Net7 Isolated functions and the logging seems to have changed significantly. Nothing we try seems to get the logging working in a consistent way.

Locally: Locally we want to be able to see all messages logged to the console from the injected ILogger in any service and we want to see messages from SQL, etc. This all worked fine in Net6 in-process but everything we try in Net7 is failing unless we set the default: "Debug" in host.json but then we see everything from all the host functions, etc. and there is way too much noise.

I've set up a simple sandbox function configured as follows:

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults()
    .ConfigureLogging(builder =>
    {
        builder.AddConsole()
            .SetMinimumLevel(LogLevel.Debug);
    })
    .Build();

host.Run();

{
  "version": "2.0",
  "logging": {
    "logLevel": {
      "default": "Debug",
      "Host.Aggregator": "None",
      "Host.Results": "None",
      "Microsoft": "None",
      "Microsoft.Hosting": "None",
      "Microsoft.Hosting.Lifetime": "None",
      "Microsoft.AspNetcore": "None",
      "Microsoft.AspNetCore.Mvc.Internal": "None",
      "Microsoft.AspNetCore.Authentication": "None",
      "Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware": "None",
      "Microsoft.Extensions.Http.DefaultHttpClientFactory": "None",
      "Microsoft.Extensions.Hosting": "None",
      "System.Net.Http.HttpClient": "None",
      "Worker": "None",
      "FunctionAppSandbox": "Debug",
      "FunctionAppSandbox.HealthCheckLogging": "Debug",
      "FunctionAppSandbox.HealthCheckLoggingFunction": "Debug"
    },
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  }
}

Unless "default": "Debug" then we see nothing in the console.

Has anyone had any luck getting debug console statements to run to the console while excluding all the noise from functions, etc?

user351711
  • 3,171
  • 5
  • 39
  • 74

1 Answers1

1

I believe that the setting you are looking for is with the key Function or Function.<YOUR_FUNCTION_NAME>:


"logging": {
   "logLevel": {
     "Function": "Debug"
...
veertien
  • 457
  • 5
  • 18