'ILoggerFactory' does not contain a definition for 'AddConsole'

I just ran into this following a course on Pluralsight. I got ahead of myself before the next slide explaining why their .AddConsole was working in the ILoggerFactory.Create.

Even though you only need using Microsoft.Extensions.Logging in your class, you need to explicitly add a package reference to your .Net Core app in order for the .AddConsole method to be found.

dotnet add package Microsoft.Extensions.Logging.Console

and add this using statement to your code

using Microsoft.Extensions.Logging;

Try using ServiceCollection to configure logging in core 3.0

private IServiceCollection ConfigureLogging(IServiceCollection factory)
      factory.AddLogging(opt =>
      return factory;

There is a seperate issue at play, previously the signature for AddConsole() expected an ILoggerFactory, that has since changed to an ILoggerBuilder, as hinted at in the error message.

The following it seems is the new way to stand up a new Console logger:

var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());