Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
like image 638
Ian Munro Avatar asked Nov 26 '18 15:11

Ian Munro


2 Answers

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"
      }
    }
  }
}
like image 150
Jerry Liu Avatar answered Oct 13 '22 15:10

Jerry Liu


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

Source: Monitor Azure Functions - Disable built-in logging

like image 36
rickvdbosch Avatar answered Oct 13 '22 16:10

rickvdbosch