I have an aplication deployed in azure with application insight with different log levels (Information,Error,Debug).All types of logs are storing in app insight.Now my application is stable and dont want to store every logs inside app insight.How we can do that without changing any code in backend.Is it possible to restrict this through Application Insight only?Note: Asuming my deployed configuration level in Information mode. And want to restrict some of the information mode logs through Application insight
It’s possible via configuration (appsettings.json/web.config/whatever you have).Here’s an example of such configuration section from appsettings.json:
"Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" }, "ApplicationInsights": { "LogLevel": { "Default": "Warning", } } }
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
},
"ApplicationInsights": {
"Default": "Warning",
}
Also, if the intention is to save money by reducing logging you can specify sampling level for Application Insight instance in Azure. Having 10% sampling means only 10% of your logging entries will be sent to Application Insight.