I have a function app that uses a table client.
svc.AddAzureClients(bldr =>
{
var serviceUrl = tableStorageSection["ServiceUrl"] ?? throw new ArgumentNullException("Missing value for Values:TableStorage:ServiceUrl");
bldr.UseCredential(new DefaultAzureCredential())
.AddTableServiceClient(new Uri(serviceUrl));
});
When I run the function locally, this client spits out a bunch of logs.
I don’t want to see those, I only want the logs from my own code. However I do not seem to be able to disable it. Here’s what I have in my host.json file.
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
},
"LogLevel": {
"Default": "Information",
"MyApi": "Debug",
"Azure": "None",
"System": "None",
"Microsoft": "None"
},
"Console": {
"IncludeScopes": false,
"FormatterName": "MyFormatter"
},
"EventSource": {
"LogLevel": {
"Default": "None"
}
}
}
}
I even created a custom formatter that outputs a logentry’s category to see if the logs come from a special category, but it seems my formatter is not being used by this logger.
Am I missing something here?
2
Answers
I was able to tune the logging by calling the ConfigureLogging method on the HostBuilder
I think your best option is to look into using an ITelemetryProcessor. This middleware intercepts ApplicationInsights telemetry and allows you to transform, filter, etc
e.g. something like this:
You’ll obviously need to setup the filtering to match the requirements of your issue.
Set it up in DI like this: