2

I have one serice myservice which run using upstart. It create logs files in /var/log/upstrart/ directory.

My service is generating too much logs, I have to work on that, till that time, I have to rotate my logs file based on size instead of time. My default configuration for logrotate is.

/var/log/upstart/*.log {
        daily
        missingok
        rotate 7
        compress
        notifempty
        nocreate
}

Can I override this only for myservice ?

Can write my won logrotate.conf and add in /etc/init.d/myservice folder and it will override the existing config?

1

Basically, if myservice is run using upstart, it has a configuration file /etc/init/myservice.conf and possibly a compatibility file /etc/init.d/myservice, but the latter is not a directory. It is very nonstandard to have subdirectories under either /etc/init or /etc/init.d.

That said, it is a very bad idea to change files which are part of the distro, because your changes might get overridden by an upgrade. All distros have mechanisms to avoid that, but you can never be sure they will work. So don’t mess up with /etc/logrotate.d/upstart or wherever the stanzas you quote are from. This means you cannot have your log file under /var/log/upstart.

The easiest solution for you is to create a directory /var/log/myservice/, edit the file /etc/init/myservice.conf to instruct your service to log to /var/log/myservice/myservice.log (this is the trickiest part, read below) and then create a file /etc/logrotate.d/myservice with the stanzas you want.

Serverfault has some hints on how to instruct your daemon to log somewhere else (you usually divert logging from upstart to syslog, then tell syslog where to log). I cannot tell you more since I know nothing about your service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.