19

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)

2 Answers 2

22

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"
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

7 Comments

Can the "MyFunctionName" be set during deployment via an ARM template or script as the name of my function changes for each customer?
@IanMunro I am afraid not. ARM template has no control over host.json, which is actually part of a project rather than an Azure configurable resource.
@lanMunro Do you mind accepting the solution to your original question? You could post a new question about ARM deployment to draw more attention, perhaps some experts could offer useful advice or workaround.
Whilst this does fix the problem, it has an issue if the name of the Function is changed when deployed. I have marked this as accepted as it does work but needs extra steps when changing the name on the fly.
This works well, but it not only prevents you from seeing the default info logs, it also prevents you to see your custom information logs... Do you know a way to prevent default messages like executing/executed while keeping the ones you did yourself?
|
3

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

Source: Monitor Azure Functions - Disable built-in logging

2 Comments

I tried this but the messages are still being logged to Application Insights.
What is Function.MyFunctionName.User here? Is it Namespace.ClassName.MethodName?

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.