Logging in .NET Core without DI?

As per Ilyas and bokibegs comments in Scotts answer here is the currently working code for .NET 5.0:

using Microsoft.Extensions.Logging;
var factory = LoggerFactory.Create(builder => {
    builder.AddConsole();
});

var logger = factory.CreateLogger<T>();

This requires the Microsoft.Extensions.Logging and Microsoft.Extensions.Logging.Console nuget packages.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)