errorMessages Property

Log Parser

errorMessages Property

Returns a collection of strings containing the messages of errors, parse errors, or warnings that occurred during the last invocation of the moveNext method.

Read-only property.

Script Syntax

value = objLogRecordSet.errorMessages;


Return Value

A collection of Strings containing error messages.


Remarks

  • The object returned by the errorMessages property implements a single read-only _NewEnum property. The _NewEnum property retrieves an IEnumVARIANT interface on an object that can be used to enumerate the collection.
    The _NewEnum property is hidden within scripting languages (JScript and VBScript). Applications written in the JScript language handle objects implementing the _NewEnum property as Enumerator objects or with the for...in statement, while applications written in the VBScript language handle objects implementing the _NewEnum property with the For Each...Next statement.
  • If you want to retrieve parse error messages, make sure that the maxParseErrors property of the LogQuery object is set to a value different than -1. If the value of this property is -1 (the default value), the parse error messages will be discarded, and the errorMessages collection will contain a single message stating the total number of parse errors occurred.


Examples

JScript example:

var oLogQuery = new ActiveXObject("MSUtil.LogQuery");

// Make sure that parse error messages are collected
oLogQuery.maxParseErrors = 100;

// Create Input Format object
var oIISW3CInputFormat = new ActiveXObject("MSUtil.LogQuery.IISW3CInputFormat");

// Create query text
var strQuery = "SELECT c-ip FROM <1> WHERE cs-uri-stem LIKE '%hitcount.asp'";

// Execute query and receive a LogRecordSet
var oRecordSet = oLogQuery.Execute( strQuery, oIISW3CInputFormat );

// Check if errors occurred
if(oLogQuery.lastError != 0)
{
        WScript.Echo("Errors occurred!");

        var oMessages = new Enumerator( oLogQuery.errorMessages );
        for(; !oMessages.atEnd();  oMessages.moveNext())
        {
            WScript.Echo("Error message: " + oMessages.item());
        }            
}

// Visit all records
while( !oRecordSet.atEnd() )
{
	// Get a record
	var oRecord = oRecordSet.getRecord();

	// Get first field value
	var strClientIp = oRecord.getValue( 0 );

	// Print field value
	WScript.Echo( "Client IP Address: " + strClientIp );

	// Advance LogRecordSet to next record
	oRecordSet.moveNext();

        // Check if errors occurred
        if(oRecordSet.lastError != 0)
        {
            WScript.Echo("Errors occurred!");

            var oMessages = new Enumerator( oRecordSet.errorMessages );
            for(; !oMessages.atEnd();  oMessages.moveNext())
            {
                WScript.Echo("Error message: " + oMessages.item());
            }            
       }
}

// Close LogRecordSet
oRecordSet.close();

VBScript example:

Dim oLogQuery
Dim oIISW3CInputFormat
Dim strQuery
Dim oRecordSet
Dim oRecord
Dim strClientIp

Set oLogQuery = CreateObject("MSUtil.LogQuery")

' Make sure that parse error messages are collected
oLogQuery.maxParseErrors = 100

' Create Input Format object
Set oIISW3CInputFormat = CreateObject("MSUtil.LogQuery.IISW3CInputFormat")

' Create query text
strQuery = "SELECT c-ip FROM <1> WHERE cs-uri-stem LIKE '%hitcount.asp'"

' Execute query and receive a LogRecordSet
Set oRecordSet = oLogQuery.Execute ( strQuery, oIISW3CInputFormat )

' Check if errors occurred
If oLogQuery.lastError <> 0 Then

    WScript.Echo "Errors occurred!"

    For Each strMessage In oLogQuery.errorMessages
        WScript.Echo "Error Message: " + strMessage
    Next

End If


' Visit all records
DO WHILE NOT oRecordSet.atEnd

	' Get a record
	Set oRecord = oRecordSet.getRecord

	' Get first field value
	strClientIp = oRecord.getValue ( 0 )

	' Print field value
	WScript.Echo "Client IP Address: " & strClientIp

	' Advance LogRecordSet to next record
	oRecordSet.moveNext

        ' Check if errors occurred
        If oRecordSet.lastError <> 0 Then

            WScript.Echo "Errors occurred!"

            For Each strMessage In oRecordSet.errorMessages
                WScript.Echo "Error Message: " + strMessage
            Next

        End If
LOOP

' Close RecordSet
oRecordSet.close


See also:

LogRecordSet Object
Log Parser COM API Overview
C# Example


© 2004 Microsoft Corporation. All rights reserved.