Closed StandNorthStar closed 1 year ago
I want to verify the logrus output log and view the log in real time through tail -f. But the resulting log file must be reopened to see the latest content.
I don't know why, can you give me some advice
logrus version: logrus v1.8.1 golang version: go1.16.6 --- test code start ---
func main() { logger.SetFormatter(&logrus.TextFormatter{TimestampFormat: "2006-01-02 15:04:05", DisableColors: true}) logger.Level = logrus.TraceLevel logger.ReportCaller = true
file, _ = os.OpenFile("./test.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) logger.SetOutput(io.MultiWriter(file)) for i:=1; i<10;i++ { fmt.Println("start :", i) logger.Info(fmt.Sprintf("mine: %d", i)) time.Sleep(time.Second * 5) }
} --- test code end ---
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
I want to verify the logrus output log and view the log in real time through tail -f. But the resulting log file must be reopened to see the latest content.
I don't know why, can you give me some advice
logrus version: logrus v1.8.1 golang version: go1.16.6 --- test code start ---
func main() { logger.SetFormatter(&logrus.TextFormatter{TimestampFormat: "2006-01-02 15:04:05", DisableColors: true}) logger.Level = logrus.TraceLevel logger.ReportCaller = true
} --- test code end ---