Skip to content

Commit

Permalink
Introduce AddNLog with NLog-config parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot committed Sep 25, 2019
1 parent cca338b commit 4ebbfae
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/NLog.Extensions.Logging/Extensions/ConfigureExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,32 @@ public static ILoggingBuilder AddNLog(this ILoggingBuilder factory, NLogProvider
factory.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, NLogLoggerProvider>(s => new NLogLoggerProvider(options)));
return factory;
}

/// <summary>
/// Enable NLog as logging provider for Microsoft Extension Logging
/// </summary>
/// <param name="builder"></param>
/// <param name="config">New NLog config.</param>
/// <returns></returns>
public static ILoggingBuilder AddNLog(this ILoggingBuilder builder, LoggingConfiguration config)
{
factory.AddNLog();
LogManager.Configuration = config;
return factory;
}

/// <summary>
/// Enable NLog as logging provider for Microsoft Extension Logging
/// </summary>
/// <param name="builder"></param>
/// <param name="configFileRelativePath">relative path to NLog configuration file.</param>
/// <returns></returns>
public static ILoggingBuilder AddNLog(this ILoggingBuilder builder, string configFileRelativePath)
{
factory.AddNLog();
LogManager.LoadConfiguration(configFileRelativePath);
return factory;
}
#endif

/// <summary>
Expand Down

0 comments on commit 4ebbfae

Please sign in to comment.