Apache logs on a daily basis without logrotate
Custom Log is the feature used to Create a new log file everyday automatically with out using log rotate.
CustomLog "|/usr/sbin/rotatelogs /var/log/httpd/log/access.%Y-%m-%d.log 86400" combined.
Adding that to your site's vhost will create log files that include the current date in their name, like access.2013-01-20.log.
With out any restart like logrotate, this feature will automatically rotate the logs
The last argument above is the rotation time in seconds – here being 86400 (= 60 * 60 * 24) which causes a new log file each day at midnight. If you want to switch to new logs more frequently adjust accordingly, e.g. "... access.%Y-%m-%d_%H-%M.log 60" to have one log file for each minute.
When unsure, run "which rotatelogs" to check where the rotatelogs binary lives.
If you still want to have your old logs gzipped and cleaned up you should be able to configure logrotate to do this for you.
Also, this can be a solution for heavily loaded sites to avoid disk I/O due to log generation: Put your logfiles into a ram drive (/dev/shm ) and write them to the filesystem every few minutes with a custom shell script. Be advised that in that time frame a server crash (or reboot, if not taken care of) means that those in-memory log files are lost.
No comments:
Post a Comment