hpcloud / tail

Go package for reading from continously updated files (tail -f)
MIT License
2.71k stars 503 forks source link

Windows watch isnotexist file, then create it and write some text, but can't print the text #117

Open xkeyideal opened 7 years ago

xkeyideal commented 7 years ago

Windows OS, go 1.7.4

cfg := tail.Config{ReOpen: true, MustExist: false, Follow: true} t, err := tail.TailFile("D:\log\hotelprice\server\hotelprice_log4.log", cfg) if err != nil { fmt.Println(err) } for line := range t.Lines { fmt.Println(line.Text) }

the hotelprice_log4.log file is not exist.

  1. create the file hotelprice_log4.log
  2. open the file, then write contents, close it but the program can't print the contents
dvas0004 commented 7 years ago

In windows the default inotify doesn't work too well... try using polling instead:

cfg := tail.Config{ReOpen: true, MustExist: false, Follow: true, Poll: true}

Does that help at all?