After the log file via http

For security reasons (I'm a developer), I donโ€™t have access to the command line on our production servers where the log files are written. I can, however, access these log files through HTTP. Is there a utility in the form of "tail -f" that can "follow" in a text file using only HTTP?

+7
text logging tail
source share
4 answers

This can be done if the HTTP server accepts requests to return parts of the resource. For example, if the HTTP request contains a header:

Range: bytes = -500

the response will contain the last 500 bytes of the resource. You can get this and then parse it in strings, etc. I do not know of any ready-made clients who will do this for you - I will write a script to do this work.

You can use Hurl to experiment with headings (from public resources).

+6
source

I wrote a bash script for the same purpose. You can find it here https://github.com/maksim07/url-tail

+1
source

You can use the small java utility to read the log file through Http using the Apache HTTP Library.

HttpClient client = HttpClientBuilder.create().build(); HttpGet request = new HttpGet(uri); HttpResponse response = client.execute(request); BufferedReader rd = new BufferedReader(new InputStreamReader( response.getEntity().getContent())); String s = ""; while ((s = rd.readLine()) != null) { //Process the line } 
+1
source

You can use PsExec to execute a command on a remote computer. The tail command for windows can be found at http://tailforwin32.sourceforge.net/

If it should be HTTP, you can write a lightweight web service to achieve this easily. for example, read text in a specified file from a string from 0 to 200.

0
source

All Articles