Quickstart with AWStats and IIS 7

AWStats is a free, Perl-based analyzer for log files. To get results quickly on a Windows Server 2008 with IIS 7 you only have to follow a few steps. These are not well documented in the AWStats documentation and require some time of research. This post will show you how to set up AWStats with IIS7 in only a few minutes.

  1. Install Perl, e.g. ActivePerl. There are 32-bit and 64-bit versions available. Make sure that Perl is added to your PATH environmental variable. The ActivePerl installer usually provides this option during the installation.
  2. Install AWStats. Remember the path AWStats is installed. Paths used below are based on the installation folder of AWStats. In this example we use c:awstats.
  3. Run the configuration script at c:\awstatstoolsawstats_configration.pl. Follow the on screen instructions. This will create a default configuration file in c:\awstatswwwrootcgi-bin e.g. called awstats.www.example.org.config. The site name www.example.org depends on whatever site name was provided while running the script. When asked for the Apache Web server path type in none.AWStats Configuration File
  4. Open the configuration file awstats.www.example.org.config with any text editor of your choice.
  5. AWStats already supports IIS, however, it is required to tweak the config file. First change the entry for LogFile. Log files for IIS might be found at c:inetpublogsLogFilesW3SVCNNN where NNN is a different number for each web site, IIS creates log files for. Change the entry toLogFile=”c:awstatstoolslogresolvemerge.pl c:inetpublogsLogFilesW3SVC1*.log |”

    This will merge all log files for a site provided by IIS. Adjust the paths corresponding to your installations and desired log file folders.

  6. The AWStats configuration file offers the possibility to set the LogFormat to IIS (LogFormat=2), however, the log entries provided by a standard installation of IIS 7 won’t match. The AWStats documentation recommends to change the settings of IIS. The change will take effect only after restarting the Web site and is only valid for entries after that particular moment. Consequently, this is not an option if you are going to analyze the logs of the last 12 months where the original settings were used. To make AWStats work with the standard log format of IIS 7 change the LogFormattoLogFormat=”%time2 %other %method %url %other %query %other %host %other %code % %other %other %bytesd”
  7. Change SiteDomain and HostAliases to meet the settings of your site.
  8. Change to c:awstatswwwrootcgi-binand runawstats.pl -config=www.example.org

    This will build the statistics database for AWStats.

  9. To create output runawstats.pl -config=www.example.org –output –staticlinks > …example_org_stats.html
  10. Not that example_org_stats.html is created one folder up. In case you do miss this, the output will not work correctly until you adapt the entries for DirCgi and DirIcons in the configuration file.
  11. The output file is now located in c:awstatswwwroot. You might want to create a Virtual Directory or set up a Web site to view the reports via the Web or your Intranet.AWStats Output

Repeat steps 3-7 fore each site you want to create reports for. Repeat step 8 and 9 every time you want to create a new report.

11 Comments

  1. monika

    Reply

    Hi,

    Thanks for your post. I had to set up AWstats on a windows server 2008 and I used your article. Would you mind explaining list of fields in LogFormat (I copied it below), why is %other repeated and there is a % after %code?

    LogFormat=”%time2 %other %method %url %other %query %other %host %other %code % %other %other %bytesd”

  2. Reply

    @monika: I think the extra % at % %other is there by accident. However both %other entries are needed as the IIS log format had entries at these positions I didn’t use for the my particular setup.

  3. Reply

    Hi

    Thanks for the information.
    I used this line in my conf file:
    LogFile=”c:awstatstoolslogresolvemerge.pl c:inetpublogsLogFilesW3SVC16*.log |”

    where W3SVC16 is the logfile for my http://www.weirdweird.com site (i think)

    this works fine and i do get statistics now.

    Strange thing is this morning i did find a new folder W3SVC22 with log file .

    how do i know witch W3SVCNNN log file belong to what site?
    and does that change when i add a site?

    regards
    Frank

  4. Reply

    Actually, I did not dig that deep into IIS to figure out which log directories are related to which sites. That’s definitely one of the things on my "figure out" list.

  5. Reply

    Hi Andreas

    I have the stats working now.
    main page and list pages

    but i dont see the drop dowm box to change the month.
    Any idee what this could be?

    regards
    Frank

  6. Reply

    Hi Frank, glad the tips helped you. Unfortunately, I have only dealt with the setup described in this post. Actually, I did not investigate into the setup of the user interface.

  7. Macleena

    Reply

    Hi
    my example_org_stats.html file is not created.
    what will be the entries for the DirCgi and DirIcons in the configuration file?

    Thanks & Regards,
    Macleena

  8. asa

    Reply

    could you please help me to get logformat of this:

    2013-03-19 23:59:30 174.29.71.96 GET “http://www.wipo.int:80/export/sites/www/madrid/en/fees/xls/fees.xls” 200 1337824 4.142 – 720 “Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:10.0.2) Gecko/20100101 Firefox/10.0.2” “http://www.wipo.int/madrid/en/fees/” – “” “1337344” Success 480 “” “” “” “”

    2013-03-19 23:59:58 206.190.75.9 GET “http://www.wipo.int:80/sme/en/documents/pdf/technology_transfer.pdf” 200 21003 0.107 – 477 “Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22” “https://www.google.com/” – “” “20502” Success 501 “” “” “” “”

      • asa

        Reply

        @Andreas, the current apache custom log format is “LogFormat “%t \”%m %U\” %>s %b %D \”%{User-Agent}i\”” shortPS

Leave a Reply to Andreas Heil Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.