Enable ILogger by default - #853
Conversation
…nd enable ILogger Provider by default for Warning or above logs.
|
Sergey Kanzhelev (@SergeyKanzhelev) Pavel Krymets (@pakrym) Ramjot Singh (@RamjotSingh) Please review when you get a chance! thanks in advance. |
|
|
||
| // By default, all logs Warning or above is captured. | ||
| // AddFilter is additive | ||
| loggingBuilder.AddFilter<Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider>("Default", LogLevel.Warning); |
There was a problem hiding this comment.
I wonder if we are messing with the ILogger infra here. This can already be done from the config which is read as part of ILogger setup. Hiding this statement this deep in SDK might be non-intuitive.
There was a problem hiding this comment.
I'd be interested in David Fowler (@davidfowl)'s opinion here. Ideally, custom middleware authors would wire up all of the services requisite for their expected behavior. If someone uses AddApplicationInsights, for instance, we'd presume all trace, exception - everything, by default - goes to Application Insights, and that any service wire-ups required for that goal to be "easy" or even "invisible" to the developer.
There was a problem hiding this comment.
Since users updatng to this new SDK version has not explicitly made a decision to send ILogger logs to AI, i'd like to just sent Warning or above to AI. Without this, we could end up sending too much logs to AI. (negative surprises when billing comes). Since the runtime itself logs using ILogger, we have experienced user complaints about too much AI logs. (#603)
I'd open to all suggestions here. We want to balance between 'easy/auto capture of ILogger logs' and 'too much noise'.
There was a problem hiding this comment.
By default, only "Warning" or above LogLevel logs are sent to ApplicationInsightsProvider for all categories. But this can be easily configured by user either in code or using appsettings.json.
I added more description here: #854
…rought by Microsoft.Extensions.Logging.ApplicationInsights
…oft/ApplicationInsights-aspnetcore into cithomas/iloggerbydefault
|
Sergey Kanzhelev (@SergeyKanzhelev) can you review? |
Sergey Kanzhelev (SergeyKanzhelev)
left a comment
There was a problem hiding this comment.
generally looks OK
| <PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" Version="2.10.0-beta2" /> | ||
| <PackageReference Include="Microsoft.AspNetCore.Hosting" Version="1.0.2" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration" Version="1.0.2" /> | ||
| <PackageReference Include="Microsoft.AspNetCore.Hosting" Version="1.0.2" /> |
There was a problem hiding this comment.
will Microsoft.AspNetCore.Hosting.Abstractions be enough?
There was a problem hiding this comment.
Likely yes, but i don't want to make un-related changes to this PR. Will revisit all package references in a separate PR.
| if (options == null) | ||
| { | ||
| options = Options.Create(new ApplicationInsightsLoggerOptions()); | ||
| options = Options.Create(new Microsoft.ApplicationInsights.AspNetCore.Logging.ApplicationInsightsLoggerOptions()); |
There was a problem hiding this comment.
This should not be needed. IOptions give a default instance if one does not exist.
There was a problem hiding this comment.
I guess you can ignore this too considering this is old code.
|
|
||
| // NetStandard2.0 has a package reference to Microsoft.Extensions.Logging.ApplicationInsights, and | ||
| // enables ApplicationInsightsLoggerProvider by default. | ||
| #if NETSTANDARD2_0 |
There was a problem hiding this comment.
If I install in Net461 project which one gets picked up? NetStandard or NetFX? My sinking suspicision is that it will pick up NetFX. We can choose to live with it but we should know it (and maybe put a comment here).
There was a problem hiding this comment.
NetFX will always "win" over netstandard2.0
| <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" /> | ||
| <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.0.0" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.0" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.0" /> |
There was a problem hiding this comment.
This should also be coming from Microsoft.Extensions.Logging.AI so you can skip it here.
There was a problem hiding this comment.
Likely yes, but i don't want to make un-related changes to this PR. Will revisit all package references in a separate PR.
…crosoft.Extensions.Configuration.Json
…oft/ApplicationInsights-aspnetcore into cithomas/iloggerbydefault
Fix Issue #854
For significant contributions please make sure you have completed the following items:
Changes in public surface reviewed
Design discussion issue #
CHANGELOG.md updated with one line description of the fix, and a link to the original issue.
The PR will trigger build, unit tests, and functional tests automatically. If your PR was submitted from fork - mention one of committers to initiate the build for you.
If you want to to re-run the build/tests, the easiest way is to simply Close and Re-Open this same PR. (Just click 'close pull request' followed by 'open pull request' buttons at the bottom of the PR)
Please follow [these] (https://github.com/Microsoft/ApplicationInsights-aspnetcore/blob/develop/Readme.md) instructions to build and test locally.