8

I'm using upstart on Ubuntu to manage services. It writes to /var/log/upstart/<service>.log. Errors in this file don't have timestamps, which makes it difficult to diagnose problems.

Is there a way -- a stanza of some kind in the config file -- to tell upstart to write timestamps with its log output?

Scott
  • 21,211
  • 8
  • 65
  • 72
blueimpb
  • 377
  • 3
  • 11

3 Answers3

4

You can try using annotate-output shell script from the devscripts package:

Source code here.

Udi
  • 29,222
  • 9
  • 96
  • 129
0

There may be a much more elegant way to do what you want, but I've found the following ghetto method to be sufficiently effective :

           echo "`date` : Doing the next thing..."
dampier
  • 4,996
  • 1
  • 21
  • 18
-1

Your service should maintain the dates/timing... The logs which appear in the logs under /var/log/upstart/ are the output of your upstart script .

Also you can add a pre-start and a pre-stop section into your conf file, to print the time before the service is ran and the timing after the service has stopped:

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