Open TENX-S opened 6 months ago
package main import ( "gopkg.in/natefinch/lumberjack.v2" "log" "time" ) func main() { lj := &lumberjack.Logger{ Filename: "test.log", MaxSize: 5, // megabytes MaxBackups: 3, } if err := lj.Close(); err != nil { panic(err) } log.SetOutput(lj) go func() { for { log.Println(time.Now().Format(time.RFC3339Nano)) } }() time.Sleep(time.Second * 3) }
I believe there should be no content in test.log, as the file was closed before writing. But it turns out the Close method has no effect on Logger
Close
Logger
I believe there should be no content in test.log, as the file was closed before writing. But it turns out the
Close
method has no effect onLogger