Yusuf Demir
Yusuf Demir

Reputation: 79

Disable Unnecessary Log Collections for Azure Functions App

I run a Kusto query for detect the which logs are collecting in my C# function app and then I see there is too much unnecessary log collections in storage : enter image description here

I want disable all log collections except for "AppExceptions", all other logs are not necessary for me. (Especially I want to turn off "AppRequests" and "AppMetrics") How can I disable them?

Azure functions version: v3

Upvotes: 3

Views: 2106

Answers (1)

Delliganesh Sevanesan
Delliganesh Sevanesan

Reputation: 4786

If you don't want to collect all log information from your app you have to configure the log categories in your app.

  1. Mention the log category to ignore the log level which you don't want to add in Application insights. Function.<YOUR_FUNCTION_NAME>, Function.<YOUR_FUNCTION_NAME>.User, Host.Aggregator, Host.Results, Microsoft & Worker.
{
  "version": "2.0",

  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request" // Exclude the Request
      }
    },
    "fileLoggingMode": "always",
    "logLevel": {
      "default": "Error", // It will log Error  or higher level log
      "Host.Results": "Error",
      "Function": "Error",
      "Host.Aggregator": "Error",
      "Function.Function1": "Error",
      "Function.Function1.User" : "Error"
    }
  }
}
  1. Use "excludedTypes" to avoid collecting the mentioned log level. In the above code it will ignore the Request level logs.
  2. Configure the log levels Ms-Doc has Higher level so that it will collect high priority level logs like Error, Critical and None. In the above host.json file I am collection all High level logs Error or higher.

You can edit host.json in App Service Editor / Kudu if your app already in production.

enter image description here

  1. If you want to disable the default built-in logging you can remove the AzureWebJobsDashboard in an Application Settings. (It is recommended for High load function).

Upvotes: 1

Related Questions