I have a log file and want to create a webpage (possibly Python but not strictly) that will work much like unix "tail -f filename" command works (show new log lines when they are written to file).
So that user will continuously see log right in browser.
How would you implement this?
Monitoring a File for Changes The tail -f option lets you view the last ten lines of the file. This option is useful for tracking log files in real-time as this command will update when new data is added to the same file. If the original file changes, the header will display which lines were altered.
From main method start executor service to start log file tailer, i.e. crunchifyExecutor. execute(crunchify_tailF); which internally calls run() Also call appendData() method which will add new line to file every 5 seconds. Once new line will be added to file, tailer will pick and print it to Eclipse Console.
In less , you can press Ctrl-C to end forward mode and scroll through the file, then press F to go back to forward mode again. Note that less +F is advocated by many as a better alternative to tail -f .
I implemented this using jquery (.ajax) and php (json).
The flow is essentially as follows:
In my specific implementation, i did the following:
See my longpolling/realtime tail implementation using jquery and php here: https://github.com/richardvk/web_file_tail
Tailon is a python webapp that, among other things, provides tail -f
like functionality. In addition, wtee (a sister project of tailon) can make all its stdin viewable in the browser - its use is identical to the unix tee
command: tail -f filename | wtee
Scullog, having capability of sharing the local drive to the browser. Stream the log file via Socket.IO over browser. It run on any platform such as windows/linux/mac. It run as service or standalone mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With