Log Parser allows users to develop custom input formats and use them with both the command-line Log Parser executable and with the Log Parser scriptable COM components.
There is no requirement on the language that can be used to implement a custom input format; for example, custom input formats can be implemented using any of the following languages:
Custom input formats are developed as COM objects implementing the methods of the ILogParserInputContext COM interface. There are two ways to write a COM object that implements the methods of this interface: implementing the ILogParserInputContext interface directly, or implementing the IDispatch (Automation) interface exposing the methods of the ILogParserInputContext interface.
Custom input format COM objects must be registered with the COM infrastructure in order to be accessible by Log Parser. This task can be usually achieved using the regsvr32.exe tool distributed with the Windows OS. The following command registers a custom input format COM object implemented as a dynamic link library (dll):
C:\>regsvr32 myinputformat.dllThe following command registers a custom input format COM object implemented as a scriptlet JScript or VBScript file:
C:\>regsvr32 myinputformat.wsc
Once developed and registered with the COM infrastructure, custom input formats can be used with either the command-line Log Parser executable, or with the Log Parser scriptable COM components.
With the command-line Log Parser executable, custom input formats are used through the COM input format, which allows users to specify the ProgID of the custom COM object and eventual run-time properties.
As an example, let's assume that we have just developed a custom
input format, and that its ProgID is
"MySample.MyInputFormat".
With the COM input format, the custom COM object can be used as
follows:
C:\>logparser "SELECT * FROM inputfile" -i:COM -iProgID:MySample.MyInputFormatIn the example above, "inputfile" stands for the specific from-entity recognized by the custom input format.
If we implemented our COM object through an Automation
interface, we could also have our object support custom
properties, and set them through the COM input format as
shown in the following example:
C:\>logparser "SELECT * FROM inputfile" -i:COM -iProgID:MySample.MyInputFormat -iCOMParams:ExtendedFields=onFor more information on the COM input format, refer to the COM Input Format reference.
With the Log Parser scriptable COM components, custom input format objects are passed as the inputFormat argument to the Execute or ExecuteBatch methods of the LogQuery object.
The following VBScript example shows how our
"MySample.MyInputFormat" custom COM object can be used with the Log
Parser scriptable COM components:
Dim oLogQuery Dim oMyInputFormat Dim oCSVOutputFormat Dim strQuery Set oLogQuery = CreateObject("MSUtil.LogQuery") ' Create our custom Input Format object Set oMyInputFormat = CreateObject("MySample.MyInputFormat") ' Create Output Format object Set oCSVOutputFormat = CreateObject("MSUtil.LogQuery.CSVOutputFormat") oCSVOutputFormat.tabs = TRUE ' Create query text strQuery = "SELECT TimeGenerated, EventID INTO C:\output.csv FROM System" strQuery = strQuery & " WHERE SourceName = 'Application Popup'" ' Execute query oLogQuery.ExecuteBatch strQuery, oMyInputFormat, oCSVOutputFormatFor more information on the Log Parser scriptable COM components, see Log Parser COM API Overview, and COM API Reference.
Log Parser comes with three custom input format samples, located
in the "Samples\COM" folder:
For more information on custom input format plugins and the
ILogParserInputContext interface, refer to the COM Input Format Plugins reference.
© 2004 Microsoft Corporation. All rights reserved.