Azure-docs: Make it clear that Log categories/levels are not inherited by ApplicationInsights provider

Created on 17 Apr 2020  Â·  6Comments  Â·  Source: MicrosoftDocs/azure-docs

After banging my head on why we were not seeing Information logs on AI and reading this page at least 3 times and thinking I was doing something stupid, I found this other issue https://github.com/MicrosoftDocs/azure-docs/issues/39784 with the exact same problem.

The answer was that the ApplicationInsights logging provider does not inherit from the top-level logging level/category. In order to send other log levels other than Default, one has to duplicate the settings for the ApplicationInsights provider.

This is fine and I understand the reasoning behind this. But I strongly believe this should be stated clear here in this page so people can configure their apps properly.

In our app we put some information logs which are important and helpful for troubleshooting. We could change to log Warning instead but that IMHO removes the intent of the log which was informational.

I believe this section: Create filter rules in configuration with appsettings.json has to be changed to better reflect the behavior. This JSON in particular is pretty confusing:

{
  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    },
    "ApplicationInsights": {
      "LogLevel": {
        "Microsoft": "Error"
      }
    }
  }
}

When reading this my expectation was correct: For all providers the Default category was to log Warning, and for the ApplicationInsights provider the level for Microsoft would be Error. The rest would still be Warning as configured above. So I went ahead and used the same "concept" but my Default top LogLevel is Information and the problem happened and I ended up on the other issue mentioned earlier.

So, if I want to send information logs to AI from my app, I need to do this:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information"
      "Microsoft": "Warning"
    },
    "ApplicationInsights": {
      "LogLevel": {
        "Default": "Information"
        "Microsoft": "Warning"
      }
    }
  }

Which.. we have to agree is a bit strange. I can't just put "Default": "Information" inside ApplicationInsights because then it will use Information level for all categories, sending a lot of stuff to AI. To make it work I have to define again the other categories


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Azure-Monitosvc Pri1 application-insightsubsvc assigned-to-author product-question triaged

All 6 comments

@joaopgrassi Thanks for the feedback. We are actively investigating and will get back to you soon.

@joaopgrassi Thanks for the feedback! I have assigned the issue to the content author to evaluate the requested enhancement and update as appropriate.

Thank you so much for the detailed notes, and our apologies for the confusion this caused. I am adding updating this doc to next month's sprint.

@mrbullwinkle no worries and thank you all for the fast response on this! One could argue that the docs _somewhat_ talks about this behavior, but yeah I'm sure things can be more clear. Would help everyone.
Just to confirm the approach I showed is correct then? Meaning, repeat all the categories inside the ApplicationInsights provider section.

Thanks for posting this comment. I was experiencing the same thing and could not understand why.

Hey everyone, sorry for the nagging but I wonder if there's any news on this? Specifically, does my reasoning and "solution" is the correct approach? I want to go ahead and change some of our services to start sending information logs to App insights, but want to make sure I'm doing it correctly/following the recommendations.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JamesDLD picture JamesDLD  Â·  3Comments

ianpowell2017 picture ianpowell2017  Â·  3Comments

bdcoder2 picture bdcoder2  Â·  3Comments

Agazoth picture Agazoth  Â·  3Comments

varma31 picture varma31  Â·  3Comments