Ubuntu: Change logging directory/file for an Upstart service



Question:

I have an upstart service that it fills up the space. I need to move the logs from /var/log/upstart to a different directory /pub/data/logs/order_server. I tried to do it using

console log --logdir /pub/data/logs/order_server  

but it gives an error

start: Unknown job: order_server  

checking the file

$ init-checkconf /etc/init/order_server.conf  ERROR: failed to ask Upstart to check conf file  

The story is similar to this one. I ended up doing the hack exec /path/to/my/daemon --arg1 --arg2 >/mnt/log/XYZ 2>&1 as someone suggested.

The following is the service conf file

# Ubuntu upstart file at /etc/init/order_server.conf  description "order server dev version"        start on (local-filesystems and net-device-up)  stop on runlevel [06]    respawn  respawn limit 10 5    exec /pub/integration_prod/integration/order_server.sh >> /pub/data/logs/order_server/order_server.log 2>&1  

Now the log file location is changed to the new location but getting it difficult to rotate the logs. The log file gets zipped up but a new log file is not created.

the upstart rotation looks something like this

/var/log/upstart/*.log /pub/data/logs/order_server/order_server.log {          daily          missingok          rotate 3          compress          notifempty          nocreate  }  

My initial intention is to fix it by using the console log option as suggested here. I hope someone can help.


Solution:1

The cookbook says --logdir is a command-line option, which means it's not an option that goes into an upstart job file, but on the command-line of Upstart itself. You can verify this in the init(8) manual page, cf. http://manpages.ubuntu.com/manpages/precise/man8/init.8.html

   --logdir directory            Write   job   output   log  files  to  a  directory  other  than            /var/log/upstart.  

In other words, it's a global option, not a per-job option.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »