/// <summary> /// Adds a NLog logger named 'NLogLogger' to the factory. /// </summary> /// <param name="builder">The <see cref="ILoggingBuilder"/> to use.</param> /// <param name="nLoggingConfiguration">Add NLog logging configuration.</param> public static ILoggingBuilder AddNLogLogger(this ILoggingBuilder builder, LoggingConfiguration nLoggingConfiguration = null) { var provider = new NLogLoggerProvider(); if (nLoggingConfiguration != null) { provider.SetupLoggingConfiguration(nLoggingConfiguration); } builder.AddProvider(provider); return(builder); }
/// <summary> /// Adds a NLog logger named 'NLogLogger' to the factory. /// </summary> /// <param name="services">The <see cref="IServiceCollection"/> to use.</param> /// <param name="nLoggingConfiguration">Add NLog logging configuration.</param> /// <param name="configurationSection">The configuration section that maps to <see cref="NLogLoggerSettings"/></param> public static IServiceCollection AddNLogLogger(this IServiceCollection services, IConfigurationSection configurationSection, LoggingConfiguration nLoggingConfiguration = null) { NLogLoggerSettings nLogSettings = configurationSection != null?configurationSection.Get <NLogLoggerSettings>() : new NLogLoggerSettings(); var provider = new NLogLoggerProvider(nLogSettings); if (nLoggingConfiguration != null) { provider.SetupLoggingConfiguration(nLoggingConfiguration); } services.AddSingleton(provider); return(services); }
/// <summary> /// Adds a NLog logger named 'NLogLogger' to the factory. /// </summary> /// <param name="builder">The <see cref="ILoggingBuilder"/> to use.</param> /// <param name="nLoggingConfiguration">Add NLog logging configuration.</param> /// <param name="configurationSection">The configuration section that maps to <see cref="NLogLoggerSettings"/></param> public static ILoggingBuilder AddNLogLogger(this ILoggingBuilder builder, IConfigurationSection configurationSection, LoggingConfiguration nLoggingConfiguration = null) { NLogLoggerSettings nLogSettings = configurationSection != null?configurationSection.Get <NLogLoggerSettings>() : new NLogLoggerSettings(); var provider = new NLogLoggerProvider(nLogSettings); if (nLoggingConfiguration != null) { provider.SetupLoggingConfiguration(nLoggingConfiguration); } builder.AddProvider(provider); return(builder); }
/// <summary> /// Adds a NLog logger named 'NLogLogger' to the factory. /// </summary> /// <param name="services">The <see cref="IServiceCollection"/> to use.</param> /// <param name="nLoggingConfiguration">Add NLog logging configuration.</param> /// <param name="acceptedCategoryNames">The list of accepted category names.</param> /// <param name="minLevel">The logging severity level.</param> /// <param name="filter">The filter based on the log level and category name.</param> public static IServiceCollection AddNLogLogger(this IServiceCollection services, List <string> acceptedCategoryNames, LoggingConfiguration nLoggingConfiguration = null, LogLevel?minLevel = null, Func <string, LogLevel, bool> filter = null) { NLogLoggerSettings nLogSettings = new NLogLoggerSettings() { AcceptedCategoryNames = new List <string>(acceptedCategoryNames), MinLevel = minLevel, Filter = filter }; var provider = new NLogLoggerProvider(nLogSettings); if (nLoggingConfiguration != null) { provider.SetupLoggingConfiguration(nLoggingConfiguration); } services.AddSingleton(provider); return(services); }
/// <summary> /// Adds a NLog logger named 'NLogLogger' to the factory. /// </summary> /// <param name="builder">The <see cref="ILoggingBuilder"/> to use.</param> /// <param name="nLoggingConfiguration">Add NLog logging configuration.</param> /// <param name="acceptedCategoryNames">The list of accepted category names.</param> /// <param name="minLevel">The logging severity level.</param> /// <param name="filter">The filter based on the log level and category name.</param> public static ILoggingBuilder AddNLogLogger(this ILoggingBuilder builder, List <string> acceptedCategoryNames, LoggingConfiguration nLoggingConfiguration = null, LogLevel?minLevel = null, Func <string, LogLevel, bool> filter = null) { NLogLoggerSettings nLogSettings = new NLogLoggerSettings() { AcceptedCategoryNames = new List <string>(acceptedCategoryNames), MinLevel = minLevel, Filter = filter }; var provider = new NLogLoggerProvider(nLogSettings); if (nLoggingConfiguration != null) { provider.SetupLoggingConfiguration(nLoggingConfiguration); } builder.AddProvider(provider); return(builder); }