Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am working on a web application the frontend of which is developed in angular js and spring mvc and which consumes the data from a RESTful webservice. There is a scenario wherein the REST webservice executes a tail command on a log file. Now this output should be streamed on the UI.Any pointers on this would be helpful.

share|improve this question
    
How does the code work on the server side, is there an event when a new line is added to the log file? –  Ed Hinchliffe 2 days ago

1 Answer 1

Solution 1

Maybe you want to take a look into WebSockets. The idea is, that you open a contineous connection between server and client for information exchange. This could be used for receiving log file updates from server.

The scenario could be something like this:

  1. User enters the log view page and thereby subscribes for getting log file updates
  2. In the server side code, where tail command is executed, an update is sent to all subscribers
  3. User receives new log content

-> Spring Websockets <-

Solution 2

Another solution of plain polling would be to use a javascript timer function for repeating requests to your log file. Something like this:

setTimeout(function(){ queryLogFile() }, 1000);

However, this will result in a high amount of requests, so maybe you should use some kind of caching mechanism for your log file.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.