I\'ve configured my console application\'s Main
like so
var services = new ServiceCollection()
.AddLogging(logging => logging.Add
This answer isn't necessarily for .net Core or whatever dependency injection is being used by the poster. I ran across this searching for a way to fix this error using Autofac in an asp.net forms web application. The answer of logging not being "registered by default" led me to add this to my registrations:
builder.RegisterType<LoggerFactory>().As<ILoggerFactory>().SingleInstance();
builder.RegisterGeneric(typeof(Logger<>)).As(typeof(ILogger<>)).SingleInstance();
And now it works for me. This is the second time I searched for this answer and ended up here, I forgot how I fixed it the first time. So I thought I'd post my answer.