I have read this but it is for asp.net core. My code below is for a non-web console app. Visual Studio tells me that AddConsole(this ILoggerFactory,...)
is obsolete and must be replaced by AddConsole(this ILoggingBuilder,...)
.
class Program
{
static void Main(string[] args)
{
ILoggerFactory ilf = new LoggerFactory();
ilf.AddConsole(LogLevel.Information);
ILogger<Program> logger = ilf.CreateLogger<Program>();
logger.LogError("the cpu is overheating");
Console.WriteLine("waiting for logger to print");
}
}
Question
How to use the extension method AddConsole
for ILoggingBuilder
instead of ILoggerFactory
in the above case?