ActiveXperts Network Monitor 2019 proactively manages network servers, devices, databases and more.

Microsoft Resource Kits - IIS 6.0 Resource Kit

Log Parser - IIS 6.0 Resource Kit Utility on Windows-Management.com


The IIS 6.0 Resource Kit Tools helps you administer, secure, and manage IIS (Internet Information Server). Use the resource kit to query log files, deploy SSL certificates, employ custom site authentication, verify permissions, troubleshoot problems, migrate your server, run stress tests, and more.


Log Parser - Perform many tasks related to IIS log files.


Log Parser version 2.1 is a versatile tool that you can use to perform many tasks related to log files. The tool supports many different input formats, including all of the Internet Information Services (IIS) log file formats. It supports multiple output formats, including text files and database tables. Log Parser is available as a command-line tool and as a set of COM objects that support scripting.

You can use Log Parser to perform many different log-related tasks, including the following:
  • Quickly search for data and patterns in files of various formats, including IIS log files, Microsoft® Windows® operating system Event Log files, generic comma-separated value (CSV) files, World Wide Web Consortium (W3C) files, and text files.
  • Create formatted reports and Extensible Markup Language (XML) files containing data retrieved from different sources.
  • Export data to SQL tables. You can export entire files or you can filter file data to obtain only relevant entries.
  • Convert data from one log file format to another.



Syntax


The following lists the syntax for standard mode:
LogParser  [-i:input-format] [-o:output-format] query | file:query-filename [input-format-options] 
[output-format-options] [-q[:ON|OFF]] [-e:max-errors] [-iw[:ON|OFF]] [-stats[:ON|OFF]]



Sample

Print the Fields of an IIS Log File to the Screen
var logQuery=new ActiveXObject("MSUtil.LogQuery");
var recordSet=logQuery.Execute("SELECT * FROM <1>");
for(;!recordSet.atEnd(); recordSet.moveNext())
{
   var record=recordSet.getRecord();
    for(var col=0; col


Print the First Column Values of a CSV File That Has No Headers:
DIM objLogQuery : SET objLogQuery = WScript.CreateObject("MSUtil.LogQuery")
DIM objCsvInputFormat : SET objCsvInputFormat =
            WScript.CreateObject("MSUtil.LogQuery.CSVInputFormat")
DIM recordSet
objCsvInputFormat.headerRow=FALSE
SET recordSet = objLogQuery.Execute("SELECT Field1 FROM file.csv", 
                                     objCsvInputFormat)
DO WHILE NOT recordset.atEnd
    IF recordSet.getRecord().isNull(0) = TRUE THEN
         WScript.Echo("NULL")
    ELSE
         WScript.Echo(recordSet.getRecord().toNativeString(0))
END IF
recordset.MoveNext
LOOP
Generate a CSV Text File Using Values from the System Event Log:
var logQuery=new ActiveXObject("MSUtil.LogQuery");
// Allow up to 5000 errors
logQuery.maxParseErrors=5000;
var eventLogInputFormat=new ActiveXObject("MSUtil.LogQuery.EventLogInputFormat"); 
var csvOutputFormat=new ActiveXObject("MSUtil.LogQuery.CSVOutputFormat"); 
if(!logQuery.ExecuteBatch("SELECT EventID, SourceName FROM System to file.csv", 
                           eventLogInputFormat, csvOutputFormat)) 
{
    WScript.Echo("Completed succesfully"); 
}
else 
{ 
    WScript.Echo("Completed with the following errors:");
    var errors=new Enumerator(logQuery.errorMessages); 
    for(; !errors.atEnd(); errors.moveNext()) 
    { 
        WScript.Echo("ERROR:" + errors.item()); 
    } 
}
Run Against an IIS W3C Extended Log File. This query opens all of the files matching ex*.log, and it writes to the MyTable SQL table all of the entries that match the fields in the SELECT statement (time, client machine name, uri-stem, uri-query, and HTTP status) that satisfy the condition in the WHERE clause, and it orders them according to the time field. To run this query, enter:
"SELECT time, REVERSEDNS(c-ip), cs-uri-stem, cs-uri-query, 
sc-status FROM ex*.log TO MyTable WHERE (sc-status > 200 AND sc-status <> 404) OR time-taken > 30 
ORDER BY time" –o:SQL