diff --git a/src/NLog.Web.AspNetCore/AspNetExtensions.cs b/src/NLog.Web.AspNetCore/AspNetExtensions.cs index 2479d020..093e25e3 100644 --- a/src/NLog.Web.AspNetCore/AspNetExtensions.cs +++ b/src/NLog.Web.AspNetCore/AspNetExtensions.cs @@ -80,11 +80,9 @@ public static IServiceProvider SetupNLogServiceLocator(this IServiceProvider ser /// Path to NLog configuration file, e.g. nlog.config. /// > /// LogFactory to get loggers, add events etc - [Obsolete("Use UseNLog() on IWebHostBuilder, and NLog.Web.NLogBuilder.ConfigureNLog()")] public static LogFactory ConfigureNLog(this ILoggingBuilder builder, string configFileName) { - ConfigurationItemFactory.Default.RegisterItemsFromAssembly(typeof(AspNetExtensions).GetTypeInfo().Assembly); - builder.AddNLog(); + ConfigureServicesNLog(null, builder.Services, serviceProvider => serviceProvider.GetService()); return LogManager.LoadConfiguration(configFileName); } @@ -96,11 +94,9 @@ public static LogFactory ConfigureNLog(this ILoggingBuilder builder, string conf /// The logging builder /// Config for NLog /// LogFactory to get loggers, add events etc - [Obsolete("Use UseNLog() on IWebHostBuilder, and NLog.Web.NLogBuilder.ConfigureNLog()")] public static LogFactory ConfigureNLog(this ILoggingBuilder builder, LoggingConfiguration configuration) { - ConfigurationItemFactory.Default.RegisterItemsFromAssembly(typeof(AspNetExtensions).GetTypeInfo().Assembly); - builder.AddNLog(); + ConfigureServicesNLog(null, builder.Services, serviceProvider => serviceProvider.GetService()); LogManager.Configuration = configuration; return LogManager.LogFactory; }