diff --git a/NLog.Web.AspNetCore/AspNetExtensions.cs b/NLog.Web.AspNetCore/AspNetExtensions.cs index efe72729..432d7b2c 100644 --- a/NLog.Web.AspNetCore/AspNetExtensions.cs +++ b/NLog.Web.AspNetCore/AspNetExtensions.cs @@ -62,6 +62,31 @@ private static LoggingConfiguration ConfigureNLog(string fileName) #if NETSTANDARD2_0 + /// + /// Apply NLog configuration from XML config. + /// + /// This call is not needed when is used. + /// + /// The logging builder + /// Path to NLog configuration file, e.g. nlog.config. > + /// LogFactory to get loggers, add events etc + public static LogFactory ConfigureNLog(this ILoggingBuilder builder, string configFileName) + { + return NLogBuilder.ConfigureNLog(configFileName); + } + + /// + /// Configure NLog from API + /// + /// This call is not needed when is used. + /// + /// The logging builder + /// Config for NLog + /// LogFactory to get loggers, add events etc + public static LogFactory ConfigureNLog(this ILoggingBuilder builder, LoggingConfiguration configuration) + { + return NLogBuilder.ConfigureNLog(configuration); + } /// /// Use NLog for Dependency Injected loggers. @@ -89,7 +114,7 @@ public static IWebHostBuilder UseNLog(this IWebHostBuilder builder, NLogAspNetCo ServiceLocator.ServiceProvider = serviceProvider; NLogBuilder.RegisterNLogWebAspNetCore(); - + LogManager.Configuration?.Reload(); return new NLogLoggerFactory(options); @@ -100,7 +125,7 @@ public static IWebHostBuilder UseNLog(this IWebHostBuilder builder, NLogAspNetCo services.TryAddSingleton(); } - + diff --git a/NLog.Web.AspNetCore/NLogBuilder.cs b/NLog.Web.AspNetCore/NLogBuilder.cs index 414d7069..92117d54 100644 --- a/NLog.Web.AspNetCore/NLogBuilder.cs +++ b/NLog.Web.AspNetCore/NLogBuilder.cs @@ -34,20 +34,20 @@ internal static void RegisterNLogWebAspNetCore() } /// - /// Configure NLog + /// Configure NLog from XML config. /// - /// Path to NLog configuration file, e.g. nlog.config. > + /// Path to NLog configuration file, e.g. nlog.config. > /// LogFactory to get loggers, add events etc - public static LogFactory ConfigureNLog(string fileName) + public static LogFactory ConfigureNLog(string configFileName) { RegisterNLogWebAspNetCore(); - return ConfigureNLog(new XmlLoggingConfiguration(fileName)); + return ConfigureNLog(new XmlLoggingConfiguration(configFileName)); } /// - /// Configure NLog + /// Configure NLog from API /// - /// + /// Config for NLog /// LogFactory to get loggers, add events etc public static LogFactory ConfigureNLog(LoggingConfiguration configuration) {