使用最新版本logrus(v1.4.2),我無法在日志格式化程序中設置毫秒/微秒。對于以前的版本(我不記得是哪個),我只是使用以下時間格式:Formatter := new(log.TextFormatter)Formatter.TimestampFormat = "15-01-2018 15:04:05.000000"Formatter.FullTimestamp = trueFormatter.ForceColors = truelog.SetFormatter(Formatter)log.SetLevel(log.DebugLevel)不幸的是,在最新版本中,似乎不再允許這種時間戳格式。當我嘗試打印具有上述時間格式的行時,我收到以下結果:17-11-7118 17:35:46.314715而不是正確的:7-11-2019 17:35:46.314715有人知道如何配置以微秒/毫秒Logrus精度打印時間戳嗎?
1 回答

慕尼黑8549860
TA貢獻1818條經驗 獲得超11個贊
使用的時間格式無效。
使用以下時間格式修復了2006-01-02T15:04:05.999999999Z07:00
。
另一種(更人性化)時間戳格式如下:Jan _2 15:04:05.000000000
- 1 回答
- 0 關注
- 239 瀏覽
添加回答
舉報
0/150
提交
取消