Ian Munro
Ian Munro

Reputation: 267

Stop an Azure Function from logging the “Executing” and “Executed” messages

When my Azure Function is triggered, it logs “Executing” and “Executed” messages. This is fine during testing but as this Function gets triggered a lot, it is creating a lot of unwanted log messages. The logging that I have added myself is important to me but I would like to disable the Function's own “Executing” and “Executed” messages. To clarify, it is the following messages I don’t want logged:

Executing ‘MyFunctionName’ (Reason='New ServiceBus message detected……etc’)

Executed ‘MyFunctionName’ (Succeeded, Id=a99c6932-788f-439e-a7db-aad7f607d5ea)

Upvotes: 18

Views: 12721

Answers (2)

Jerry Liu
Jerry Liu

Reputation: 17790

The execution logs you want to get rid of is generated by function runtime, we can set a higher log level to filter information and keep our self-defined info.

Go to Azure portal, Platform features> Function app settings> host.json

For Function app v2, with this setting in host.json, the logs excluded are nowhere to find.

{
  "version": "2.0",
  "logging": {
    "logLevel": {
      "Function.MyFunctionName.User": "Information",
      "Function": "Error"
    }
  }
}

For v1, use ILogger instead of TraceWriter. This setting in host.json only restricts those sent to Application Insights, which means we can still see them in console or file logs.

{
  "logger": {
    "categoryFilter": {
      "categoryLevels": {
        "Host.Executor": "Error"
      }
    }
  }
}

Upvotes: 22

rickvdbosch
rickvdbosch

Reputation: 15571

To disable built-in logging, delete the AzureWebJobsDashboard app setting.

Source: Monitor Azure Functions - Disable built-in logging

Upvotes: 3

Related Questions