natefinch / lumberjack

lumberjack is a log rolling package for Go
MIT License
4.79k stars 591 forks source link

filename not match the localTime #70

Open hexingmin01 opened 5 years ago

hexingmin01 commented 5 years ago

-rw-r--r-- 1 root root 12M Jan 2 17:08 master-2019-01-02T09-08-11.581.log -rw-r--r-- 1 root root 12M Jan 2 17:08 master-2019-01-02T09-08-55.835.log -rw-r--r-- 1 root root 12M Jan 2 17:09 master-2019-01-02T09-09-36.542.log -rw-r--r-- 1 root root 12M Jan 2 17:10 master-2019-01-02T09-10-17.229.log -rw-r--r-- 1 root root 12M Jan 2 17:10 master-2019-01-02T09-10-58.189.log -rw-r--r-- 1 root root 12M Jan 2 17:11 master-2019-01-02T09-11-38.575.log -rw-r--r-- 1 root root 12M Jan 2 17:12 master-2019-01-02T09-12-22.933.log

the local time is 2019-01-02 17:12 ,but the file name is master-2019-01-02T09-12-22.933.log

xiegeo commented 5 years ago

Have you checked if root has the same timezone as your user account?

natefinch commented 5 years ago

The time zone stuff is pretty basic, I doubt there's a bug in it after all this time. Likely, whatever account is running the program lumberjack runs in simply has that timezone.

littlejiancc commented 4 years ago

You should set LocalTime : true to using the local time, otherwise it will use UTC

lumberJackLogger := &lumberjack.Logger{
    Filename:   InfoFilename,
    MaxSize:    MaxSize,
    MaxBackups: MaxBackups,
    MaxAge:     MaxAge,
    Compress:   Compress,
    LocalTime: true,
}