Timestamps in upstart logs
Asked Answered
S

3

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?

Schott answered 28/7, 2013 at 17:6 Comment(0)
M
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..."
Moralist answered 23/9, 2013 at 23:52 Comment(0)
A
4

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

Source code here.

Alrzc answered 29/3, 2015 at 17:23 Comment(0)
M
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..."
Moralist answered 23/9, 2013 at 23:52 Comment(0)
H
-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
Hazardous answered 2/9, 2017 at 5:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.