0

I've been using tailer to tail a log file for a program.

I've been running into some issues as the program I am reading the log for creates a new log file on restart (of the same name); this causes me a major issue as tailer will not follow the new logfile (of the same name) when this occurs. It is running within a thread and it has to share memory with several other locations including code that has not been called through threading. Since tailer has an active thread open and running I can't just join the thread as it is still executing code and thus it's stuck. Is there a way around this (without using multiprocessing and killing it through that)?

import tailer

for line in tailer.follow(open("mytestfile.log", encoding='utf-8')):
    #do some stuff with the line

That would be an example follow. Any recommendations to get around that?

Treatybreaker
  • 776
  • 5
  • 9
  • It's not part of `tailer` to follow **rotated log files**. Read [how-can-i-tail-a-log-file-in-python](https://stackoverflow.com/questions/12523044) and [detect-log-file-rotation-while-watching-log-file-for-modification](https://stackoverflow.com/questions/44407834) – stovfl Apr 28 '20 at 08:22
  • So I should probably seek a different solution then for tailing the file? I found the first link you posted there a while back, but found it to be somewhat CPU intensive and I had to install WSL as I am running this program on a windows box. Inotify is Linux only as well, but I know of watchdog, but only had limited success with it. I guess my best bet would be to modify the library for my needs then. I appreciate it. – Treatybreaker Apr 28 '20 at 08:26

0 Answers0