4

I'm getting a massive amount of verbose and information level logging in my Application Insights log stream when running my durable function. I tried to disable these with host.json and Serilog config without any luck.

Log output

Application Insights logging

DI

I'm using dependency injection, but nothing specific for logging (only self created classes).

host.json

{
  "version": "2.0",
  "logging": {
    "logLevel": {
      "default": "Warning",
      "DurableTask.AzureStorage": "Warning",
      "DurableTask.Core": "Warning",
      "Host.Triggers.DurableTask": "Warning",
      "Function": "Warning",
    },
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Exception"
      }
    }
  }
}

It seems that host.json is ignored and everything is pushed to the log stream.

Serilog

I also tried to add Serilog to handle the logging with the following code, but it has the same result, verbose logging is still pushed to Application Insights

[assembly: FunctionsStartup(typeof(MultiHop.Functions.Startup))]
namespace MultiHop.Functions
{
    public class Startup : FunctionsStartup
    {       
        public override void Configure(IFunctionsHostBuilder builder)
        {
            Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Warning()
                .MinimumLevel.Override("Host.Triggers.DurableTask", LogEventLevel.Warning)
                .MinimumLevel.Override("DurableTask.Core", LogEventLevel.Warning)
                .MinimumLevel.Override("DurableTask.AzureStorage", LogEventLevel.Warning)
                .MinimumLevel.Override("Function", LogEventLevel.Warning)
                .Enrich.FromLogContext()
                .Enrich.WithExceptionDetails()
                .WriteTo.Console(LogEventLevel.Warning, theme: SystemConsoleTheme.Literate)
                .CreateLogger();
                
            builder.Services.AddLogging(configure => configure.AddSerilog(Log.Logger, true));
        }
    }
}

Any idea how I can disable this verbose and information logging?

3 Answers 3

0

To reduce the verbose logging when running the azure functions locally, few settings to be added in the local.settings.json file such as Azure WebJobs Host Middleware, rpcWorkerProcess to None under log level attribute.

"logging:logLevel:Microsoft.Azure.WebJobs.Script.WebHost.Middleware.SystemTraceMiddleware": "None",
"logging:logLevel:Worker.rpcWorkerProcess": "None"

Based on your context, I found similar issue discussion on the GitHub Azure Functions Core Tools Issues #1440 where the author explained how the backend logs come from - that the functions use the different types of hosts such as .NET Host, Function Runtime Host which will acts as a parent host, child host that loads the function for running the code and those logs comes in the console based on the host.json file configuration to the inner child host.

Sign up to request clarification or add additional context in comments.

Comments

0

A way to disable the logs of AzureFunctions but not your own logging can be found here: https://github.com/anthonychu/functions-log-suppression

You will have to disable the logging for Functions (or set to whatever Log level you want) and then add the log level for user logging for each function. There is apparently no way to set log level for all user logging so you will sadly need to do it for each function.

Here is an example given by the URL and I have run it locally and it worked for me. in local.stting.json:

{
    "logging:logLevel:Microsoft": "None",
    "logging:logLevel:Worker": "None",
    "AzureFunctionsJobHost:logging:logLevel:default": "None",
    "AzureFunctionsJobHost:logging:logLevel:Host.Function.Console": "Information",
    "AzureFunctionsJobHost:logging:logLevel:Function.HttpTrigger1.User": "Information",
    "AzureFunctionsJobHost:logging:logLevel:Function.HttpTrigger2.User": "Information"
}

1 Comment

Not sure why you got downvoted, this is what worked for me and this link helped me a lot after hours or trial and errors
0

Adding my 2 cents.

As described by Anthony Chu in https://github.com/anthonychu/functions-log-suppression the log categories can be found in Application Insights.

To suppress durable task logs I added these lines to my local.settings.json

"AzureFunctionsJobHost:logging:logLevel:DurableTask": "Warning", "AzureFunctionsJobHost:logging:logLevel:Host.Triggers": "Warning", "AzureFunctionsJobHost:logging:logLevel:Host.StartUp": "Warning",

This limits the output to pretty much only informational messages for my Powershell durable functions

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.