I have a function app that only logs informational and higher. This is my Program.cs:
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureServices(services =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
var contextualization = services.BuildServiceProvider().GetService<IOptions<ExecutionContextOptions>>()?.Value;
var config = new ConfigMan(contextualization.AppDirectory);
services.AddSingleton(config);
var devOpsRepo = new EDWRepo(config.Values.DB_EDW);
services.AddSingleton<EDWRepo>(devOpsRepo);
})
.ConfigureLogging(logging => {
logging.Services.Configure<LoggerFilterOptions>(options => {
LoggerFilterRule defaltRule = options.Rules.FirstOrDefault(rule => rule.ProviderName == "Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider");
if (defaltRule is not null)
{
options.Rules.Remove(defaltRule);
}
});
})
.Build();
host.Run();
Host file:
{
"version": "2.0",
"extensions": {
"queues": {
"messageEncoding": "none"
}
},
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
},
"logLevel": {
"default": "Trace"
},
"enableLiveMetricsFilters": true
},
"logLevel": {
"default": "Trace",
"Function": "Trace"
}
}
}
And function:
[Function(nameof(VesselAddOrUpdate))]
public async Task Run([QueueTrigger("update-or-add-vessel", Connection = "QueueConnection")] QueueMessage vesselJson)
{
_logger.LogInformation($"FUNKTION HAS RUN INFO", Microsoft.ApplicationInsights.DataContracts.SeverityLevel.Information);
_logger.LogTrace($"FUNKTION HAS RUN TRACE", Microsoft.ApplicationInsights.DataContracts.SeverityLevel.Information);
}
And in my AI i can only see information:
Function is running on .NET 8.0 Isolated mode. Any suggestions?