I’m trying to control the log level for my C# Azure Function. The goal is to change the log level without having to redeploy the function. The idea is to change the Environment variables in order to achieve this.
I added an environment variable to control the log level:
enter image description here
It doesn’t seem to work, as I’m still seeing Debug and Information logging:
enter image description here
My host.json looks like this:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
},
"enableLiveMetricsFilters": true
},
"logLevel": {
"default": "Debug"
}
}
}
And Program.cs like this:
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureLogging(builder => builder.SetMinimumLevel(LogLevel.Debug))
.ConfigureServices(services =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
services.Configure<LoggerFilterOptions>(options => options.Rules.Clear());
})
.Build();
host.Run();
When i run my function app locally it works as intended when i change my local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"AzureFunctionsJobHost__logging__LogLevel__default": "Warning"
}
}
Can someone shed some light on what i’m missing? Thanks in advance.
Bastian Marschall is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.