Skip to content

Commit

Permalink
NLogLoggerProvider - Always load from appsettings when possible (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot authored Aug 30, 2021
1 parent c8dcd7e commit 14935c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
9 changes: 3 additions & 6 deletions src/NLog.Extensions.Hosting/Extensions/ConfigureExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,14 @@ private static void AddNLogLoggerProvider(IServiceCollection services, IConfigur

private static NLogLoggerProvider CreateNLogLoggerProvider(IServiceProvider serviceProvider, IConfiguration configuration, NLogProviderOptions options)
{
configuration = SetupConfiguration(serviceProvider, configuration);
NLogLoggerProvider provider = new NLogLoggerProvider(options);
configuration = SetupConfiguration(serviceProvider, configuration);
if (configuration != null)
{
if (options == null)
{
provider.Configure(configuration.GetSection("Logging:NLog"));
}

provider.Configure(configuration.GetSection("Logging:NLog"));
provider.TryLoadConfigurationFromSection(configuration);
}

return provider;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,7 @@ private static NLogLoggerProvider CreateNLogLoggerProvider(IServiceProvider serv
configuration = SetupConfiguration(serviceProvider, configuration);
if (configuration != null)
{
if (options == null)
{
provider.Configure(configuration.GetSection("Logging:NLog"));
}

provider.Configure(configuration.GetSection("Logging:NLog"));
provider.TryLoadConfigurationFromSection(configuration);
}

Expand Down

0 comments on commit 14935c2

Please sign in to comment.