When it comes to gathering statistics on web sites, you can never have enough. While one of the most popular method for tracking statistics is through services such as Google Analytics, log file analysis remains a reliable way to track your visitors as they are immune to script blockers. A widely used tool for log file analysis is the open source tool, AWStats.
Configuring Web Site Logging
In order to capture the data AWStats tracks, your sites must log the following fields:
IIS 6 Setup
To configure logging in IIS 6, open IIS Manager and right click on the Web Sites folder and select Properties.
On the Web Site tab, click the Properties button in the Enable logging section.
In the Logging Properties, configure the schedule to be daily with local time used for file naming and rollover.
On the Advanced tab, configure the required fields to be logged.
Apply your changes.
IIS 7 Setup
To configure logging in IIS 7, open IIS Manager and select Logging from the server configuration options.
In the Logging configuration, set up a single log file per site which rolls over daily using the local time for file naming.
Click the Select Fields button and check the boxes next to the required fields.
Apply your changes.
Setting Up AWStats
Download the AWStats zip package from Sourceforge. Create a folder called ‘awstats’ in your ‘C:inetpubwwwroot’ folder and extract the following files from the downloaded zip file to this folder:
Once the files are extracted, copy the “awstats.model.conf” file to a file named “awstats.domain.com.conf” (where domain.com is the site to track), open it in Notepad and configure the options as needed.
The first thing you will need to configure is the log file location, which by default is located here:
- Server 2003: C:WINDOWSsystem32LogFilesW3SVC[IIS_ID]
- Server 2008: C:inetpublogsLogFilesW3SVC[IIS_ID]
You can find the IIS ID by looking at the master site listing in IIS Manager and noting the value in the ID column next to the respective site.
Set the options in the configuration file. This file has a very good explanation of what each option does, so take a few minutes to review them. Here are a few settings of interest according to the setup above:
- LogFile=”C:inetpublogsLogFilesW3SVC1u_ex%YY-24%MM-24%DD-24.log” (Server 2008/IIS 7 where the stats are calculated daily)
- LogFile=”C:WINDOWSsystem32LogFilesW3SVC1ex%YY-4%MM-4%DD-4.log” (Server 2003/IIS 6 where the stats are calculated every 4 hours to be updated throughout the day)
- LogFormat=”date time cs-method cs-uri-stem cs-username c-ip cs-version cs(User-Agent) cs(Referer) sc-status sc-bytes”
- HostAliases=”www.domain.com 220.127.116.11″ (any other URL’s which point to your site)
- DefaultFile=”index.php index.html”
Once you have saved your configuration file, run the AWStats Perl Script to compile the stats data. The command looks like this:
C:inetpubwwwrootawstats>C:Perlbinperl.exe awstats.pl -config=domain.com
The above command assumes the following (configuration used for this article):
- The folder “C:inetpubwwwrootawstats” serves the stats through IIS.
- Perl was installed to the “C:Perl” directory.
- The config file is named “awstats.domain.com.conf”.
Finally, you can access the stats data through your browser. This URL is publically available for anyone to view unless you configure security via IIS. To test our configuration, just browse to:
Scheduling Stats Update
One of the configurations we set in the config file is the ‘LogFile’ location which defines the amount of hours to subtract from the date portions of the file. So to automate the process of compiling your stats, set up a Windows Scheduled Task which runs the command you used above to build the stats on the interval you configured.
Download AWStats (zip package)