diff --git a/src/NLog.Web.AspNetCore/AspNetExtensions.cs b/src/NLog.Web.AspNetCore/AspNetExtensions.cs index 7d0dc151..ac57f1a7 100644 --- a/src/NLog.Web.AspNetCore/AspNetExtensions.cs +++ b/src/NLog.Web.AspNetCore/AspNetExtensions.cs @@ -240,6 +240,23 @@ public static ILoggingBuilder AddNLogWeb(this ILoggingBuilder builder, Func + /// Configure NLog from API + /// + /// The logging builder + /// NLog LogFactory + /// Options for logging to NLog with Dependency Injected loggers + public static ILoggingBuilder AddNLogWeb(this ILoggingBuilder builder, LogFactory logFactory, NLogAspNetCoreOptions options) + { + AddNLogLoggerProvider(builder.Services, null, options, (serviceProvider, config, opt) => + { + logFactory = logFactory ?? LogManager.LogFactory; + var provider = CreateNLogLoggerProvider(serviceProvider, config, opt, logFactory); + return provider; + }); + return builder; + } + /// /// Use NLog for Dependency Injected loggers. ///