Open kluhman opened 1 year ago
Hi, have you found any solutions to this?
I used to do the opposite and do something like:
"LogLevel": {
"default": "Warning",
"My.Namespace": "Information"
}
But in the isolated host this is no longer possible either.
Any update for this issue?
We met similar problem that log lower than warning will not be collected by appInsights/log analytics workspace, no matter what configuration is applied in host.json.
It's really bad that we could not get logs in production environment for debug.
An ugly workaround is to log all information with LogLevel.None, since "None" is higher than "Critical" so it will be collected:
_logger.Log(LogLevel.None, "Here is the message");
Below is the configuration of our Function App:
However, by default, the Application Insights SDK adds a logging filter that instructs the logger to capture only warnings and more severe logs. If you want to disable this behavior, remove the filter rule as part of service configuration:
Maybe this issue helps?
https://github.com/Azure/azure-functions-dotnet-worker/issues/1182
And also this one: https://github.com/Azure/azure-functions-dotnet-worker/issues/1025
Seems in islotaed mode the logging configurations are not automatically loaded. So I added them manually and still maintaining the logLevel in my host.json
file:-
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddJsonFile("host.json", optional:true, reloadOnChange: true)
.AddEnvironmentVariables()
.....
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureLogging((builder, logging) =>
{
logging.AddConfiguration(config.GetSection("logging"));
})
.ConfigureServices(services => {
.....
am facing similar issues with recent .net9 upgrades. Appinsights are filling up with debug logs even if we have put the filters in appsettings.json. This is increasing our appinsight cost and makes troubleshooting difficult since lot of noise logs is visible. Please advise. Also does this also effect the .net8 apI side also ? am seeing some rise in logs there too.
even with this change its not working>
.ConfigureLogging((builder, logging) =>
{
logging.AddConfiguration(config.GetSection("logging"));
})
I am trying to disable the Information log messages emitted by the
HttpClient
as they make about ~50% of all logs sent to our Application Insights and are beginning to cost quite a bit on a high volume service. I have tried creating a filter for theSystem.Net.Http.HttpClient
category in both thehost.json
and in app settings, but it does not appear to be working either way. I have confirmed this filter works correctly in a standard .NET application, but does not appear to be respected by the Functions host.I was able to reproduce this in a minimal reproduction project, all the code for this is included below.
Program.cs
host.json
local.settings.json
HttpGateway.cs
TestFunction.cs
Repro steps
TestFunction
via HTTP RequestHttpClient
Examples of log messages from
HttpClient
Start processing HTTP request GET https://example.com/
Sending HTTP request GET https://example.com/
Received HTTP response headers after 221.7623ms - 200
End processing HTTP request after 234.0382ms - 200
Expected behavior
No Information level messages from
HttpClient
are displayed in the Console outputActual behavior
Information level messages from
HttpClient
are displayed in the Console outputKnown workarounds
Adding this to the host builder in
Program.cs
seems to have the desired effect, but requires hardcoded logging configuration rather than accepting my configuration settings.