Posts Tagged apache

Rotating Apache Logs – The Easy, Automatic Way

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.

Tags: , ,

What Happened in March 2006?

I’m always on the look out for interesting data, particularly when it comes to data dealing with either retanetcraft-surveyil or technology.  I came across a monthly survey taken by Netcraft that analyzes what software websites are running.  I was quite surprised to see in March of 2006 a spike in IIS (Microsoft) and a decline in Apache (Linux).  Furthermore it seems that for the past two years this pattern has held to the point where Apache has lost some serious marketshare to IIS.

Now, don’t get me wrong — I’m not anti-Apache.  I run 4 sites off Apache and only one off of IIS.  I will admit, though, the more I have to maintain the more I look at IIS because it is easier to manage than Apache.

Aside from all that, I’m left to wonder — what happened in March of 2006?  Sometimes the devil is in the details.

Tags: , , ,

Switch to our mobile site

Stats by WP SlimStat