5

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
    }
Fdv
  • 385
  • 2
  • 5
  • 14

2 Answers2

11

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
}
Fdv
  • 385
  • 2
  • 5
  • 14
3

To get production-20160710.log instead of production.2016-07-10.log you can do:

dateext
dateformat -%Y%m%d

/var/www/redmine/log/production.log
{
        extension .log
}

The dateformat can actually be left out as that is the default.

Job Evers
  • 4,077
  • 5
  • 20
  • 26