Class ApplicationInsightsLoggerFactoryExtensions
- Namespace
- Microsoft.Extensions.Logging
- Assembly
- Microsoft.ApplicationInsights.AspNetCore.dll
Extension methods for Microsoft.Extensions.Logging.ILoggerFactory that allow adding Application Insights logger.
public static class ApplicationInsightsLoggerFactoryExtensions
- Inheritance
-
ApplicationInsightsLoggerFactoryExtensions
- Inherited Members
Methods
AddApplicationInsights(ILoggerFactory, IServiceProvider)
Adds an ApplicationInsights logger that is enabled for Microsoft.Extensions.Logging.LogLevel.Warning or higher.
[Obsolete("ApplicationInsightsLoggerProvider is now enabled by default when enabling ApplicationInsights monitoring using UseApplicationInsights extension method on IWebHostBuilder or AddApplicationInsightsTelemetry extension method on IServiceCollection. From 2.7.0-beta3 onwards, calling this method will result in double logging and filters applied will not get applied. If interested in using just logging provider, then please use Microsoft.Extensions.Logging.ApplicationInsightsLoggingBuilderExtensions.AddApplicationInsights from Microsoft.Extensions.Logging.ApplicationInsights package. Read more https://aka.ms/ApplicationInsightsILoggerFaq")]
public static ILoggerFactory AddApplicationInsights(this ILoggerFactory factory, IServiceProvider serviceProvider)
Parameters
factory
ILoggerFactoryUsed to configure the logging system and create instances of ILogger from the registered ILoggerProviders.
serviceProvider
IServiceProviderThe instance of IServiceProvider to use for service resolution.
Returns
- ILoggerFactory
AddApplicationInsights(ILoggerFactory, IServiceProvider, LogLevel)
Adds an ApplicationInsights logger that is enabled for Microsoft.Extensions.Logging.LogLevels of minLevel or higher.
[Obsolete("ApplicationInsightsLoggerProvider is now enabled by default when enabling ApplicationInsights monitoring using UseApplicationInsights extension method on IWebHostBuilder or AddApplicationInsightsTelemetry extension method on IServiceCollection. From 2.7.0-beta3 onwards, calling this method will result in double logging and filters applied will not get applied. If interested in using just logging provider, then please use Microsoft.Extensions.Logging.ApplicationInsightsLoggingBuilderExtensions.AddApplicationInsights from Microsoft.Extensions.Logging.ApplicationInsights package. Read more https://aka.ms/ApplicationInsightsILoggerFaq")]
public static ILoggerFactory AddApplicationInsights(this ILoggerFactory factory, IServiceProvider serviceProvider, LogLevel minLevel)
Parameters
factory
ILoggerFactoryUsed to configure the logging system and create instances of ILogger from the registered ILoggerProviders.
serviceProvider
IServiceProviderThe instance of IServiceProvider to use for service resolution.
minLevel
LogLevelThe minimum Microsoft.Extensions.Logging.LogLevel to be logged.
Returns
- ILoggerFactory
AddApplicationInsights(ILoggerFactory, IServiceProvider, Func<string, LogLevel, bool>)
Adds an ApplicationInsights logger that is enabled as defined by the filter function.
[Obsolete("ApplicationInsightsLoggerProvider is now enabled by default when enabling ApplicationInsights monitoring using UseApplicationInsights extension method on IWebHostBuilder or AddApplicationInsightsTelemetry extension method on IServiceCollection. From 2.7.0-beta3 onwards, calling this method will result in double logging and filters applied will not get applied. If interested in using just logging provider, then please use Microsoft.Extensions.Logging.ApplicationInsightsLoggingBuilderExtensions.AddApplicationInsights from Microsoft.Extensions.Logging.ApplicationInsights package. Read more https://aka.ms/ApplicationInsightsILoggerFaq")]
public static ILoggerFactory AddApplicationInsights(this ILoggerFactory factory, IServiceProvider serviceProvider, Func<string, LogLevel, bool> filter)
Parameters
factory
ILoggerFactoryUsed to configure the logging system and create instances of ILogger from the registered ILoggerProviders.
serviceProvider
IServiceProviderThe instance of IServiceProvider to use for service resolution.
filter
Func<string, LogLevel, bool>
Returns
- ILoggerFactory
AddApplicationInsights(ILoggerFactory, IServiceProvider, Func<string, LogLevel, bool>, Action)
Adds an ApplicationInsights logger that is enabled as defined by the filter function.
[Obsolete("ApplicationInsightsLoggerProvider is now enabled by default when enabling ApplicationInsights monitoring using UseApplicationInsights extension method on IWebHostBuilder or AddApplicationInsightsTelemetry extension method on IServiceCollection. From 2.7.0-beta3 onwards, calling this method will result in double logging and filters applied will not get applied. If interested in using just logging provider, then please use Microsoft.Extensions.Logging.ApplicationInsightsLoggingBuilderExtensions.AddApplicationInsights from Microsoft.Extensions.Logging.ApplicationInsights package. Read more https://aka.ms/ApplicationInsightsILoggerFaq")]
public static ILoggerFactory AddApplicationInsights(this ILoggerFactory factory, IServiceProvider serviceProvider, Func<string, LogLevel, bool> filter, Action loggerAddedCallback)
Parameters
factory
ILoggerFactoryUsed to configure the logging system and create instances of ILogger from the registered ILoggerProviders.
serviceProvider
IServiceProviderThe instance of IServiceProvider to use for service resolution.
filter
Func<string, LogLevel, bool>Filter action.
loggerAddedCallback
ActionThe callback that gets executed when another ApplicationInsights logger is added.
Returns
- ILoggerFactory