Closed mkulkarni15 closed 7 years ago
log.SetFlags(log.LstdFlags | log.LUTC) helped me.
So, yeah, Localtime on Lumberjack just controls the timestamp appended to rolled log files. What gets output inside the logs is completely beyond the control of Lumberjack. It just writes what you tell it to write.
I have tried setting LocalTime false, true and not using the parameter. Neither of which is resulting in UTC time prepended to the log. Is there something obvious i am missing?
package main
import ( "log" "gopkg.in/natefinch/lumberjack.v2" "time" "fmt" ) func main() {
log.SetOutput(&lumberjack.Logger{ Filename: "sed.log", MaxSize: 50, // megabytes MaxAge: 28, //days LocalTime: false, }) localTime := time.Now() utcTime := localTime.UTC()
}
go run lumber.go Local Time: 2017-05-09 12:13:26.205047356 -0700 PDT UTC Time: 2017-05-09 19:13:26.205047356 +0000 UTC
cat sed.log
2017/05/09 12:13:26 DEBUG %s 2017-05-09 12:13:26.205047356 -0700 PDT 2017/05/09 12:13:26 DEBUG %s 2017-05-09 19:13:26.205047356 +0000 UTC