3

I am planning some infrastructural architecture. It seems as if logrotate configuration files in /etc/logrotate.d usually handle exactly one type of log rotation.

My question: Would it be possible to create a file like /etc/logrotate.d/my_company, which configures multiple different log rotations for different log files? Is it possible to combine the content of multiple logrotate configuration files into one file?

Example:

/var/log/service_1
{
    compress
    delaycompress
    notifempty
    daily
    rotate 31
}

/var/log/service_2
{
    daily
    rotate 7
}

1 Answer 1

2

Yes, there should be no problem having multiple definitions in a file. The logrotate.conf just appends the contents of all the logrotate.d/* files into its main logrotate.conf. To illustrate, the config file for apt includes multiple log files in one:

/var/log/apt/term.log {
    rotate 12
    monthly
    compress
    missingok
    notifempty
}

/var/log/apt/history.log {
    rotate 12
    monthly
    compress
    missingok
    notifempty
}

Logrotate configuration works per log file, not per module or service.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .