You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 10, 2020. It is now read-only.
Enable ApplicationInsightsLoggerProvider by calling AddApplicationInsights() extension method on LoggingBuilder.
Proposing to change this behaviour, to automatically enable ApplicationInsightsLoggerProvider, when ApplicationInsights collection is enabled with either services.AddApplicationInsightsTelemetry() or IWebHostBuilder.UseApplicationInsights() methods.
With this change, users no longer have to add additional nuget or do any change to enable ILogger provider for ApplicationInsights.
Notes:
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.
For eg:
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddApplicationInsightsTelemetry();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddLogging((logging) =>
{
// For categories beginning with Microsoft, sent only Error or above
// logging.AddFilter<ApplicationInsightsLoggerProvider>("Microsoft", LogLevel.Error);
// For every other categories, sent only Warning or above
//logging.AddFilter<ApplicationInsightsLoggerProvider>("", LogLevel.Warning);
});
}
This new feature will be available only for NETSTANDARD2.0 or above, as the dependent package Microsoft.Extensions.Logging.ApplicationInsights is only from NETSTANDARD2.0 or above.
If you need to send ILogger logs to applications from an older apps, please use the AddApplicationInsights extension method on ILoggerFactory as shown here. Please note that this is now a deprecated way.
If old provider was enabled with now obsolete extension method AddApplicationInsights of ILoggerFactory, please remove it - otherwise it'll result in double logging.
Currently enabling ApplicationInsightsLoggerProvider is an additional step on top on enabling ApplicationInsights.
i.e users have to
Proposing to change this behaviour, to automatically enable ApplicationInsightsLoggerProvider, when ApplicationInsights collection is enabled with either services.AddApplicationInsightsTelemetry() or IWebHostBuilder.UseApplicationInsights() methods.
With this change, users no longer have to add additional nuget or do any change to enable ILogger provider for ApplicationInsights.
Notes:
For eg:
or in appsettings.json
If you need to send ILogger logs to applications from an older apps, please use the
AddApplicationInsightsextension method on ILoggerFactory as shown here. Please note that this is now a deprecated way.If old provider was enabled with now obsolete extension method
AddApplicationInsightsofILoggerFactory, please remove it - otherwise it'll result in double logging.