.NET 8 - Isolated Worker - IHostBuilder - Unable to log DEBUG or TRACE to Application Insights from Linux S1 App Service Plans #2883
Labels
Needs: Triage (Functions)
potential-bug
Items opened using the bug report template, not yet triaged and confirmed as a bug
Description
The Guide for running C# Azure Functions in the isolated worker mode page does a really great job outlining how to properly setup logging with Application Insights.
However, the page highlight two syntax flavors, one named
IHostBuilder
and the other namedIHostApplicationBuilder
.Using the
IHostBuilder
syntax, I find that it is impossible to sendDebug
orTrace
logs to Application Insights out of the box.Here is the syntax used (as taken straight from the documentation referred to above)
In contrast to the
IHostApplicationBuilder
syntax, I find that the code shown here does not automatically load the existingappsettings.json
file. As a result, the log levels and categories are not setup at all with this code, when running on a Linux S1 App Service Plan.I then need to add the following two fragments of code which are not in the documentation.
The first fragment registers the
appsettings.json
file as the source for configuration:The second fragment actually loads and configure log levels and categories from the
Logging
configuration section:When the code is complete, this gives us full control on log levels and categories when running on Windows App Service Plans.
However, it does not work when running on Linux S1 App Service Plans.
There, I am unable to emit logs lower than
Information
.Is the documentation correct ?
Is this a bug in the Application Insights SDK (I find this unlikely) ?
Is this a bug on Linux S1 App Service Plans ? In that case, how shall I report that bug ?
Can someone explain why there are two different syntaxes to achieve seemingly the same things ?
Steps to reproduce
HelloWorldHttpTrigger
under namespaceAzFuncUni.Logging
..csproj
file.Program.cs
with the following code using theIHostBuilder
pattern:appsettings.json
with the following contents:appsettings.json
file is copied to the output folder.HttpTrigger
function with the following code:Notice that the logs
DBUG
andTRAC
are not emitted. Only logsINFO
,WARN
andERR
are recorded to application insights.Program.cs
with the one documented forIHostApplicationBuilder
like so:Notice that, this time,
TRAC
andDBUG
logs are, indeed, recorded in Application Insights, along withINFO
,WARN
andERR
logs.The text was updated successfully, but these errors were encountered: