Logrus: how to show time fields in default format

Created on 21 Sep 2016  路  2Comments  路  Source: sirupsen/logrus

I used default format to print log, but there is only log level info, log msg which I wrote and some fields I added, but where is the time field, isn't it added automatically?

Most helpful comment

kind of, it shows how long the program has been running. can set a new formatter to show the full timestamp

logrus.Info("duration")

formatter := &logrus.TextFormatter{
    FullTimestamp: true,
}
logrus.SetFormatter(formatter)
logrus.Info("timestamp")

output

INFO[0000] duration                                     
INFO[2016-09-23T21:55:52-04:00] timestamp

All 2 comments

kind of, it shows how long the program has been running. can set a new formatter to show the full timestamp

logrus.Info("duration")

formatter := &logrus.TextFormatter{
    FullTimestamp: true,
}
logrus.SetFormatter(formatter)
logrus.Info("timestamp")

output

INFO[0000] duration                                     
INFO[2016-09-23T21:55:52-04:00] timestamp

@daniel-huckins that's what I want, thank you!!!

Was this page helpful?
0 / 5 - 0 ratings