1

I want to display a logfile on a webpage, essentially as though I were running

tail -f logfile.txt

and the output were displayed in a scrolling part of a webpage (with the latest updates appearing at the bottom of the section with older text scrolling upwards out of view).

This is as part of a monitoring screen for testing the system I am working on.

So far I am using long polling from the browser (using XMLHttpRequest) , calling an api that is returning the whole logfile. The webservice is using FileSystemWatcher to monitor for updates to the logfile, returning the whole logfile to the browser when updates are made.

This obviously is sending the whole logfile whenever it is updated which is no good at all.

How do I monitor the log file so that I can retrieve just the lines that have been added?

UPDATED

I used this answer http://stackoverflow.com/a/24993767/3195477 (rather than the accepted answer).

Dave M
  • 172
  • 3
  • 9
  • 1
    Store the last line index that you sent, when the file changes reload it and only send what lies beyond that index, re-save the last index. – Alex K. Jun 21 '18 at 14:29
  • Upvoters perhaps need a refresher of [ask] –  Jun 21 '18 at 14:41

0 Answers0