Rob Bowman
Rob Bowman

Reputation: 8711

Azure Function v4 - How Turn Off Host Logging

I have a C# Azure Function app that gets deployed via DevOps build and release pipeline.

It was running on the v3 Functions runtime. I've recently updated the project file and bicep template of the function app so that it runs on v4.

The app is configured to log to Azure Sql through Serilog. since the update I've noticed many thousands of additional log entries from the Azure Functions Host

The logging section of my appsettings.json file is shown below. My understanding is these would be used where equivalent values are available to the Function App as environment variables - through the configuration settings section of the function app?

"Logging": {
"LogLevel": {
  "Default": "Error"
},
"ApplicationInsights": {
  "LogLevel": {
    "Default": "Information"
  }
}
}

I tried following the answer to this post in order to suppress the logging by adding the following entries in the function app's application settings:

"name": "AzureFunctionsJobHost__Logging__LogLevel__Microsoft",
"value": "Error"

"name": "AzureFunctionsJobHost__Logging__LogLevel__Azure",
"value": "Error"

I restarted the function app but noticed no difference in the logs. Here's an example of one of the unwanted log records (all logged with a with a level of "Information"):

<properties>
<property key='requestId'>bcc9a52c-fb8b-4a89-bb1c-9ed08eb305c4</property>
<property key='status'>200</property>
<property key='reasonPhrase'>OK</property>
<property key='seconds'>0.0048284</property>
<property key='EventSourceEvent'>Response [bcc9a52c-fb8b-4a89-bb1c-9ed08eb305c4] 200 OK (00.0s)</property>
<property key='EventId'>
    <structure type=''>
        <property key='Id'>5</property>
        <property key='Name'>Response</property>
    </structure>
</property>
<property key='SourceContext'>Azure.Core</property>

Upvotes: 1

Views: 1481

Answers (1)

Rob Bowman
Rob Bowman

Reputation: 8711

Sorry to anyone that looked at this - I was being an idiot!

Another project had recently been added to the solution and I was looking at config for the wrong project.

For anyone struggling with a similar problem, I recommend trying serilog config that can be adjusted at runtime rather than having to redeploy C# containing your Serilog LoggerConfiguration object. This github link explains how

Upvotes: 1

Related Questions