Skip to content

Commit

Permalink
Merge pull request #483 from snakefoot/master
Browse files Browse the repository at this point in the history
AddNLog-methods for ILoggingBuilder
  • Loading branch information
304NotModified authored Sep 26, 2019
2 parents fa802de + 1355ced commit 1ed597d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/NLog.Web.AspNetCore/AspNetExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,30 @@ public static LogFactory ConfigureNLog(this ILoggingBuilder builder, LoggingConf
return LogManager.LogFactory;
}

/// <summary>
/// Apply NLog configuration from XML config.
/// </summary>
/// <param name="builder">The logging builder</param>
/// <param name="configFileName">Path to NLog configuration file, e.g. nlog.config. </param>
public static ILoggingBuilder AddNLog(this ILoggingBuilder builder, string configFileName)
{
ConfigureServicesNLog(null, builder.Services, serviceProvider => serviceProvider.GetService<IConfiguration>());
LogManager.LoadConfiguration(configFileName);
return builder;
}

/// <summary>
/// Configure NLog from API
/// </summary>
/// <param name="builder">The logging builder</param>
/// <param name="configuration">Config for NLog</param>
public static ILoggingBuilder AddNLog(this ILoggingBuilder builder, LoggingConfiguration configuration)
{
ConfigureServicesNLog(null, builder.Services, serviceProvider => serviceProvider.GetService<IConfiguration>());
LogManager.Configuration = configuration;
return builder;
}

/// <summary>
/// Use NLog for Dependency Injected loggers.
/// </summary>
Expand Down

0 comments on commit 1ed597d

Please sign in to comment.