Thanks for sharing your host.json
logging info. We noticed you have two logLevel
sections, which might be causing the problem.
Could you try removing this part:
"logLevel": {
"default": "Information",
"Microsoft.EntityFrameworkCore.Database.Command": "Warning"
}
So your logging
section looks like this:
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request;Exception"
},
"enableLiveMetricsFilters": true,
"logLevel": {
"Microsoft.EntityFrameworkCore.Database.Command": "Warning"
}
}
}
Then, restart your function and see if the SQL logs are reduced.
Additionally, to further reduce the amount of data sent to Application Insights, you can adjust the sampling settings. For example, you can set a sampling percentage to only collect a fraction of the telemetry. This can be done by adding a percentage
property to the samplingSettings
Regarding your question about dynamic configuration:
- You are correct that programmatic filtering (
loggingBuilder.AddFilter
) is a permanent code change. - The
host.json
file is the most reliable configuration based approach. - While environment variables should work, there are some inconsistencies with how the Azure Functions host handles them, especially when combined with Application Insights. The Host.json file is the most reliable configuration method.