Python Forum

Full Version: reading remote active log file?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 ,
Various implementations of tail exist in Python. You can perhaps try pygtail
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
Thank you
I will take a look
it's seem like a good solution