Reputation: 507
I have a .net Core 3.1 web app that connects to different Storage Accounts using Azure MSI. The services are initialized using the Azure.Core.Extensions nuget package.
var options = new BlobClientOptions
{
Diagnostics =
{
IsLoggingEnabled = false,
IsTelemetryEnabled = false,
IsDistributedTracingEnabled = false,
IsLoggingContentEnabled = false
},
Retry =
{
MaxRetries = 3,
Mode = RetryMode.Exponential,
NetworkTimeout = TimeSpan.FromSeconds(120),
Delay = TimeSpan.FromSeconds(0.7)
}
};
builder.AddBlobServiceClient(StorageAccountConfigurator.GetStorageAccountUri(accountName))
.WithName(accountName)
.ConfigureOptions(options);
Everything works ok, but in Application Insights I get too many traces with this message:
ManagedIdentityCredential.GetToken succeeded. Scopes: [ https://storage.azure.com/.default ]
These are traces with Severity level:Information, Category:Azure.Identity.
Azure.Identity does not appear as a independent category in the documentation:https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-6.0
I have tried to create a ApplicationInsightsFilter (implements ITelemetryProcessor) to catch such traces and exclude them from logs, but somehow they overpass it (while debugging I was not able to catch such traces).
Is there an option to stop them from appearing in the logs?
Upvotes: 3
Views: 1159
Reputation: 4776
You can specify the log levels for Azure.Identity
Package also in your appsettings.json
file as specified in the Logging Configuration and Azure SDKs Logging Microsoft docs.
For example:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Azure.Identity": "Information",
"Azure.Core": "Debug"
}
}
}
Upvotes: 2