This repository was archived by the owner on Oct 17, 2018. It is now read-only.
This repository was archived by the owner on Oct 17, 2018. It is now read-only.
Calling AddDataProtection before AddLogging pollutes service collection with NullLoggerFactory #243
Closed
Description
Order shouldn't matter. The call to AddLogging should win.
This was broken by #134.
public class Program
{
public static void Main(string[] args)
{
// Call AddDataProtection first
var services = new ServiceCollection()
.AddDataProtection()
.Services
.AddLogging(config => config.AddConsole())
.BuildServiceProvider();
// Call AddLogging first
var services2 = new ServiceCollection()
.AddLogging(config => config.AddConsole())
.AddDataProtection()
.Services
.BuildServiceProvider();
Console.WriteLine(services.GetService<ILoggerFactory>().GetType().AssemblyQualifiedName);
Console.WriteLine(services2.GetService<ILoggerFactory>().GetType().AssemblyQualifiedName);
}
}
output
Microsoft.Extensions.Logging.Abstractions.NullLoggerFactory, Microsoft.Extensions.Logging.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Microsoft.Extensions.Logging.LoggerFactory, Microsoft.Extensions.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60