Utpal Dutta
How to restricted logging into Azure Application Insights

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

By Utpal Dutta in Azure on Sep 25 2023
  • Ma Gu
    Dec, 2023 30

    It’s possible via configuration (appsettings.json/web.config/whatever you have).
    Here’s an example of such configuration section from appsettings.json:

    1. "Logging": {
    2. "LogLevel": {
    3. "Default": "Information",
    4. "Microsoft": "Warning",
    5. "Microsoft.Hosting.Lifetime": "Information"
    6. },
    7. "ApplicationInsights": {
    8. "LogLevel": {
    9. "Default": "Warning",
    10. }
    11. }
    12. }

    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.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS