Timestamps in Slip Logs

I use upstart on Ubuntu to manage services. It is written to /var/log/upstart/<service>.log . Errors in this file do not have time stamps, which makes it difficult to diagnose problems.

Is there a way - some kind of stanza in the configuration file - to say an upstart to record timestamps with the log output?

+7
logging upstart
source share
3 answers

There may be a much more elegant way to do what you want, but I found that the following ghetto method would be quite efficient:

  echo "`date` : Doing the next thing..." 
+1
source share

You can use annotate-output shell script from devscripts :

The source code is here .

+3
source share

Your service must support dates and dates ... The logs that appear in the logs under /var/log/upstart/ are the output of your upstart script.

You can also add a preliminary start and preliminary stop to your conf file to print the time before the service starts and the time after the service stops:

 pre-start script echo "[`date`] <YOUR SERVICE NAME> Starting" >> /var/log/<YOUR SERVICE NAME>.log end script pre-stop script echo "[`date`] <YOUR SERVICE NAME> Stopping" >> /var/log/<YOUR SERVICE NAME>.log end script 
0
source share

All Articles