How to tail logs from an AppFog remote server using a shell script poll?

718 Views Asked by At

Testing out AppFog and I've run into their tailing problem. Specifically, they don't offer tailing of your server. A big sticking point for me as I prefer to work on a remote dev server and without access to the logs it makes it very difficult to debug. Same with staging.

They do offer the following to pull the logs down:

af logs my-app-name --all

Which will dump whatever's in the log to your terminal. Not exactly elegant, but at least the info is there.

But it's not continuous. And having to type af logs my-app-name --all a million times will make me go out of my mind, especially while I'm trying to hunt down a bug.

So I thought I'd write a shell script that will fire the af logs command against my app server for me, and I came up with this:

#!/bin/bash

while true; do
  af logs $1
  sleep 3
done

Where $1 is the name of my app. So I'd use it like so:

af-tail my-app-name

And then every three seconds I'd get a log dump from my app server. However, I keep getting all the logs and really I'd like it to concatenate any missing entries to the existing 'stream' in my terminal, but I'm not sure how I'd go about doing that. Any help?

1

There are 1 best solutions below

0
Lloyd Moore On

Maybe this could help. I use it to monitor remote logs in my local machine.

https://gist.github.com/iolloyd/da60ef316643d7894bdf