Timestamps in upstart logs

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?


可能有一种更加优雅的方式来做你想做的事,但我发现下面的贫民窟方法足够有效:

           echo "`date` : Doing the next thing..."

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

Source code here.


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
链接地址: http://www.djcxy.com/p/73132.html

上一篇: 在Android VideoView上绘制覆盖图(HUD)?

下一篇: 新贵日志中的时间戳