You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the example for "IHostBuilder", the removing of the defaultRule is done in the "ConfigureLogging" method
usingMicrosoft.Azure.Functions.Worker;usingMicrosoft.Extensions.DependencyInjection;usingMicrosoft.Extensions.Hosting;usingMicrosoft.Extensions.Logging;varhost=newHostBuilder().ConfigureFunctionsWorkerDefaults().ConfigureServices(services =>{services.AddApplicationInsightsTelemetryWorkerService();services.ConfigureFunctionsApplicationInsights();}).ConfigureLogging(logging =>{logging.Services.Configure<LoggerFilterOptions>(options =>{LoggerFilterRuledefaultRule=options.Rules.FirstOrDefault(rule =>rule.ProviderName=="Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider");if(defaultRuleis not null){options.Rules.Remove(defaultRule);}});}).Build();host.Run();
However when I'm running my "TestLogging" function, I see the log messages being written to the "Console":
But not to "Application Insights":
After moving the same code to the "ConfigureServices" method instead of "ConfigureLogging" everything starts to work as expected.
usingMicrosoft.Azure.Functions.Worker;usingMicrosoft.Extensions.DependencyInjection;usingMicrosoft.Extensions.Hosting;usingMicrosoft.Extensions.Logging;varhost=newHostBuilder().ConfigureFunctionsWorkerDefaults().ConfigureServices(services =>{services.AddApplicationInsightsTelemetryWorkerService();services.ConfigureFunctionsApplicationInsights();services.Configure<LoggerFilterOptions>(options =>{LoggerFilterRuledefaultRule=options.Rules.FirstOrDefault(rule =>rule.ProviderName=="Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider");if(defaultRuleis not null){options.Rules.Remove(defaultRule);}});}).ConfigureLogging(logging =>{}).Build();host.Run();
Please validate if this is expected behavior. If so then kindly update the documentation? Otherwise perform the needed updates in code, so the example documentation starts to work as expected
The text was updated successfully, but these errors were encountered:
In the "Guide for running C# Azure Functions in the isolated worker model" there is a section on "Managing log levels" here:
https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=hostbuilder%2Cwindows#managing-log-levels
In the example for "IHostBuilder", the removing of the defaultRule is done in the "ConfigureLogging" method
However when I'm running my "TestLogging" function, I see the log messages being written to the "Console":
But not to "Application Insights":
After moving the same code to the "ConfigureServices" method instead of "ConfigureLogging" everything starts to work as expected.
Please validate if this is expected behavior. If so then kindly update the documentation? Otherwise perform the needed updates in code, so the example documentation starts to work as expected
The text was updated successfully, but these errors were encountered: