Configuration to include log files in subdirectories with logrotate

Tadashi Shigeoka ·  Fri, December 29, 2017

I’ll introduce the configuration to include log files in subdirectories with logrotate.

Linux | リナックス

How to include subdirectories with logrotate

Let’s look at the default logrotate configuration for Nginx as an example.

/etc/logrotate.d/nginx

Before change

/var/log/nginx/*.log {
        (omitted)
}

After change

/var/log/nginx/*.log
/var/log/nginx/*/*.log
{
        (omitted)
}

In addition to the default /var/log/nginx/.log, I added /var/log/nginx//*.log to include .log files in subdirectories under /var/log/nginx/ as targets for logrotate.

That’s all from the Gemba where I wanted to include log files in subdirectories with logrotate.