logrotate rename files with date

Right now, logrotate renames old log files to access.log.1.gz, access.log.2.gz, etc. I would prefer if it named them access.log.20090714.gz, access.log.20090715.gz, etc - one for each day.

I cannot find any option of specifying a filename pattern for the old log files. Do you know how to do this?

BTW, this is for rotating lighttpd log files, if that matters.


In /etc/logrotate.conf or /etc/logrotate.d/lighttpd, or the proper file if anywhere else, add dateext to the stanza you want to apply date suffixes.

More information from logrotate man page:

dateext

Archive old versions of log files adding a daily extension like YYYYMMDD instead of simply adding a number.


Use cronolog - it'll write logfiles with the correct filenames in the first place (eg. I generally have my webservers write logfiles as YYYY/MM/DD/access, or YYYY/MM/DD/error, and so forth). More details on configuring cronolog with lighttpd are here: http://redmine.lighttpd.net/projects/1/wiki/MigratingFromApache

(while that page mentions that server.errorlog can't be run through cronolog, there appears to be a bug report for this that has been marked as "fixed" - unfortunately i can't post more than one URL at a time, since I'm a "new" user on serverfault...)