Log event datetime with.Net Core Console logger

The feature was added into version 3 of the Microsoft.Extensions.Logging.Console(here is the pr). You can activate this with setting the TimestampFormat:

  new ServiceCollection()
     .AddLogging(opt =>
     {
         opt.AddConsole(c =>
         {
            c.TimestampFormat = "[HH:mm:ss] ";
         });
    })

Example in .NET 5 (ASP.NET Core):

public void ConfigureServices(IServiceCollection services)
{
    services.AddLogging(options =>
    {
        options.AddSimpleConsole(c =>
        {
            c.TimestampFormat = "[yyyy-MM-dd HH:mm:ss] ";
            // c.UseUtcTimestamp = true; // something to consider
        });
    });

    // ...
}

Output example:

[2020-12-13 12:55:44] info: Microsoft.Hosting.Lifetime[0] Application is shutting down...