Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register NLogProvider instead of NLogFactory #205

Merged
merged 1 commit into from
Oct 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions NLog.Web.AspNetCore/AspNetExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,29 +109,30 @@ public static IWebHostBuilder UseNLog(this IWebHostBuilder builder, NLogAspNetCo

builder.ConfigureServices(services =>
{
services.AddSingleton<ILoggerFactory>(serviceProvider =>
//note: when registering ILoggerFactory, all non NLog stuff and stuff before this will be removed
services.AddSingleton<ILoggerProvider>(serviceProvider =>
{
ServiceLocator.ServiceProvider = serviceProvider;

NLogBuilder.RegisterNLogWebAspNetCore();

LogManager.Configuration?.Reload();
return new NLogLoggerFactory(options);

return new NLogLoggerProvider(options);
});

//note: this one is called before services.AddSingleton<ILoggerFactory>
if (options.RegisterHttpContextAccessor)
{
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
}

});

return builder;
}



});
return builder;
}
#endif


Expand Down