Python Forum
reading remote active log file? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: reading remote active log file? (/thread-34056.html)



reading remote active log file? - korenron - Jun-22-2021

Hello ,
I want to be able to read a remote log file that run all the time
can I do this?
I have acess to the server , and can run the python app on the same server (no need for remote ssh\tcl\udp connection - if it will be easier to think of solution)
the reason is that I have only access to the file and not the code the create it (then I would just ask to send me the data , but I can't)
now I'm reading the file manually using 'tail -f logs/error.log' , and take action line by line
I want to read the entries and do something with them using python (send alerts , send files -- acoording tom my own rules)
the data is kind of simple syslog data

Thanks ,


RE: reading remote active log file? - Gribouillis - Jun-22-2021

Various implementations of tail exist in Python. You can perhaps try pygtail


RE: reading remote active log file? - perfringo - Jun-22-2021

Have a look at David Beazley’s Using Python Generator to Monitor Data. In my understanding it addresses your problem in concise and pythonic way


RE: reading remote active log file? - korenron - Jun-24-2021

Thank you
I will take a look
it's seem like a good solution