LogParser for IIS Log

Introduction

One commonly used tool for viewing IIS (Internet Information Services) logs is "Log Parser," a powerful command-line tool provided by Microsoft. Log Parser allows you to query, analyze, and manipulate various log files, including IIS logs, in a flexible and efficient manner.

How you can use Log Parser to view IIS logs?


1. Download and Install Log Parser

Make sure you have downloaded and installed Log Parser from the Microsoft Download Center. If you haven't installed it yet, please do so before proceeding.

2. Add Log Parser to PATH

To use Log Parser from any command prompt window, you need to add its installation directory to the system's PATH environment variable.

  • Open the Windows Control Panel.
  • Search for "Environment Variables" and click on "Edit the system environment variables."
  • In the System Properties window, click the "Environment Variables" button.
  • In the "System Variables" section, find the "Path" variable and click "Edit."
  • Click "New" and add the path to the directory where Log Parser is installed. The default installation path might be something like C:\Program Files (x86)\Log Parser 2.2

3. Open Command Prompt

To use Log Parser, you'll need to open a Command Prompt window with administrative privileges.

4. Run Log Parser Queries

Use the following command structure to run Log Parser queries on IIS logs.

LogParser "SELECT * FROM <log_file_path>" -i:IISW3C -o:DATAGRID

Replace <log_file_path> with the path to the IIS log file you want to view. The -i flag specifies the input format (in this case, IISW3C for IIS logs), and the -o flag specifies the output format (DATAGRID for a tabular view).

For example, if you want to view the latest log file for a specific website, you could use a command like this.

LogParser "SELECT * FROM C:\inetpub\logs\LogFiles\W3SVC1\u_exYYYYMMDD.log" -i:IISW3C -o:DATAGRID

5. Analyze Results

After running the command, the Log Parser will display a tabular view of the log file's contents in the Command Prompt window. You can scroll through the data to view various fields such as date, time, IP address, status code, and more.

Please note that while Log Parser is a powerful tool, it's command-line-based and may not offer the most user-friendly interface. If you prefer a more user-friendly graphical tool, you might want to consider third-party log analysis tools specifically designed for IIS logs, such as "SmarterStats," "AWStats," or "Loggly."