Feature #1580
closedRotating log file patch for mod_accesslog
Description
I patched mod_accesslog to support the automatic rotation of log files based on a strftime-style format string. This patch has been running on my custom build of lighttpd for a number of years now and has always worked well. This method of log rotation avoids the extra processes that would otherwise be required by a cronolog approach.
The patch adds the following boolean configuration item to lighttpd.conf:
accesslog.auto-rotate
If this value is set to true, then mod_accesslog will treat accesslog.filename
as a strftime-style pattern for the purposes of opening (and creating) log files. For example, the following set of configuration options would create one log file for each month, with one directory for each year:
accesslog.auto-rotate = "enable" accesslog.filename = "/var/log/lighttpd/%Y/%Y%m.access.log"
The following directory tree would eventually be created (assuming that lighttpd ran from November 2007 to March 2008):
/var/log/lighttpd/2007/200711.access.log /var/log/lighttpd/2007/200712.access.log /var/log/lighttpd/2008/200801.access.log /var/log/lighttpd/2008/200802.access.log /var/log/lighttpd/2008/200803.access.log
The patch will not check the filename pattern for a change more often than once a minute. In other words, you can rotate log files on a per-minute basis if you wish, but not on a per-second basis. The check happens each time a log file entry is about to be written, so the check could occur less frequently than once a minute if the server is not very busy.
The most recent version of this patch was based on lighttpd 1.4.15, although it appears to be compatible with 1.4.18 as well.
Files
Updated by Anonymous about 17 years ago
Nice feature - but isn't this a task for stuff like Logrotate? I can see requests such as compressing and other common log handling tasks arise. Personally, I don't think that lighttpd should handle those.
-- Lfe
Updated by malyn about 17 years ago
I agree that lighttpd should not handle things like compression; I use a cron job to do that, for example. My goal with this patch was to make a minor (especially from a performance perspective) change to the mod_accesslog module that would get me 80% of what I wanted in a log rotation feature.
I am definitely not the right person to say if this feature should become a part of the official lighttpd distribution though. Mostly I just wanted to make the patch available to anyone else who wants the same 80%.
Thanks for the comments!
Updated by stbuehler over 16 years ago
- Status changed from New to Fixed
- Resolution set to wontfix
As you need something to handle the logs anyway (like compressing, deleting old ones, ...) and logrotate already works, i think that should be enough for everyone.
Updated by matdakillah over 15 years ago
- Target version changed from 1.4.20 to 1.4.23
Hi I'm trying to use your patch in the 1.4.23 version but I got an error message in the error.log file which is:
(server.c.951) WARNING: unknown config-key: accesslog.auto-rotate (ignored)
If you can help me to fix this?
Thx.
Also available in: Atom