我正在try 从Golang log软件包过渡到Logrus.我的问题是如何定制记录消息的时间戳格式.默认值是从开始算起的秒数,但我想要"2016-03-24 17:10:15"格式.我的简单测试代码是:
package main
import (
"github.com/Sirupsen/logrus"
)
func main() {
customFormatter := new(logrus.TextFormatter)
customFormatter.TimestampFormat = "2006-01-02 15:04:05"
logrus.SetFormatter(customFormatter)
logrus.Info("Hello Walrus")
}
这可以很好地编译和运行,但时间戳格式不变.有人能解释一下为什么它不起作用吗?
谢谢