Many of my friends that I’m strictly a Microsoft Windows guy – they don’t know about the secret Linux guy that hides inside. Most of the web properties that I own (including this one) run on Linux and are served up by Ubuntu. I get my “power” from Slicehost, the best darn virtual private server provider out there. Long before I was a Windows guy I spent many an hour writing scripts and maintaining AIX systems.
Enough about that – onto the topic of this post. One of the things I like to do with my websites is rotate the Apache access log files every day so that I can more easily archive them and analyze them. Unfortunately, as common as you might think this is, it’s pretty darn hard to track down any documentation on how to do it. The thing is, once you find out how to do it, you realize how easy it is!
The trick is to use a program that comes with Apache 2.0 – rotatelogs. This guy can be found in your /usr/sbin directory on most flavors of Linux. You are going to take it and combine it with the CustomLogs directive in your configuration file to give you all the power you want. If you are running virtual hosts on your sites, you will want to put this in your configuration files for your particular site that are located in /etc/apache2/sites-enabled. (Unless you keep all your log files for all your sites in one big file, which I strongly recommend against.)
Note the following is all on one line, despite the fact it may appear to be on two in your web browser.
CustomLog "| rotatelogs /var/www/virtualdir/log/access_log.%Y-%m-%d 86400" combined
Replace your current CustomLog entry with the one above. Notice the pipe character “|” after the quotes. This will have Apache rotate your log files every 24 hours at midnight (86,400 seconds after midnight) and store them as access_log.2009-07-02 with the date portion changing every day. Unlike other solutions out there, this one will not require any restarting of your Apache server every day. You will need to use apache2ctrl restart to restart your web server after you made the changes to pick up the new configuration settings.
il or technology. I came across a 










