How do I provide ILogger in my unit tests of .NET Core code?
Starting from dotnet core 2.0 there’s a generic NullLogger<T> class available: var foo = new Foo(NullLogger<Foo>.Instance); https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.abstractions.nulllogger-1?view=aspnetcore-2.1 (docs) https://github.com/aspnet/Logging/blob/master/src/Microsoft.Extensions.Logging.Abstractions/NullLoggerOfT.cs (source) Or if you need it as part of your services: services.AddSingleton<ILoggerFactory, NullLoggerFactory>(); https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.abstractions.nullloggerfactory?view=aspnetcore-2.1 (docs)