Log event datetime with.Net Core Console logger

后端 未结 3 1713
抹茶落季
抹茶落季 2021-02-18 13:33

I\'m using logging to Console output, that built-in to .Net Core framework. Here initialization of the logger:

var serviceCollection = new ServiceCollection();
s         


        
3条回答
  •  无人共我
    2021-02-18 14:04

    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] ";
             });
        })
    

提交回复
热议问题