How to configure Logrotate with dateext and extension

Fdv picture Fdv · Jul 10, 2016 · Viewed 12.2k times · Source

I tried to configure logrotate to keep the date and the extension of the log being rotated:

With the current configuration, the file:

/var/www/redmine/log/production.log

Is logrotated in :

/var/www/redmine/log/production.-20160710log

I was expecting :

/var/www/redmine/log/production-20160710.log

Please see below an extract vof the logrotate configuration file :

cat /etc/logrotate.d/redmine

    rotate 4
    weekly
    missingok
    notifempty
    compress
    delaycompress
    sharedscripts
    dateext

    /var/www/redmine/log/production.log
    {
            create 755 www-data www-data
            extension log
    }

Answer

Fdv picture Fdv · Jul 12, 2016

I Got it !

Just added the "dateformat %Y-%m-%d." Including a "." in the format

rotate 4
weekly
missingok
notifempty
compress
delaycompress
sharedscripts
dateext
dateformat %Y-%m-%d.

/var/www/redmine/log/production.log
{
        create 755 www-data www-data
        extension log
}