diff --git a/src/NLog.Extensions.Logging/Extensions/ConfigureExtensions.cs b/src/NLog.Extensions.Logging/Extensions/ConfigureExtensions.cs index a42e0165..cc112f33 100644 --- a/src/NLog.Extensions.Logging/Extensions/ConfigureExtensions.cs +++ b/src/NLog.Extensions.Logging/Extensions/ConfigureExtensions.cs @@ -97,6 +97,32 @@ public static ILoggingBuilder AddNLog(this ILoggingBuilder factory, NLogProvider factory.Services.TryAddEnumerable(ServiceDescriptor.Singleton(s => new NLogLoggerProvider(options))); return factory; } + + /// + /// Enable NLog as logging provider for Microsoft Extension Logging + /// + /// + /// New NLog config. + /// + public static ILoggingBuilder AddNLog(this ILoggingBuilder builder, LoggingConfiguration config) + { + factory.AddNLog(); + LogManager.Configuration = config; + return factory; + } + + /// + /// Enable NLog as logging provider for Microsoft Extension Logging + /// + /// + /// relative path to NLog configuration file. + /// + public static ILoggingBuilder AddNLog(this ILoggingBuilder builder, string configFileRelativePath) + { + factory.AddNLog(); + LogManager.LoadConfiguration(configFileRelativePath); + return factory; + } #endif ///