Output Format Objects
Output Format objects provide programmatic access to the output formats supported by Log Parser.
Output Format objects are instantiated with the ProgId and the .NET COM wrapper class names specified in the following table:
Output Format | ProgId | .NET COM Wrapper Class Name |
---|---|---|
CHART | MSUtil.LogQuery.ChartOutputFormat | COMChartOutputContextClassClass |
CSV | MSUtil.LogQuery.CSVOutputFormat | COMCSVOutputContextClassClass |
DATAGRID | MSUtil.LogQuery.DataGridOutputFormat | COMDataGridOutputContextClassClass |
IIS | MSUtil.LogQuery.IISOutputFormat | COMIISOutputContextClassClass |
NAT | MSUtil.LogQuery.NativeOutputFormat | COMNativeOutputContextClassClass |
SQL | MSUtil.LogQuery.SQLOutputFormat | COMSQLOutputContextClassClass |
SYSLOG | MSUtil.LogQuery.SYSLOGOutputFormat | COMSYSLOGOutputContextClassClass |
TPL | MSUtil.LogQuery.TemplateOutputFormat | COMTemplateOutputContextClassClass |
TSV | MSUtil.LogQuery.TSVOutputFormat | COMTSVOutputContextClassClass |
W3C | MSUtil.LogQuery.W3COutputFormat | COMW3COutputContextClassClass |
XML | MSUtil.LogQuery.XMLOutputFormat | COMXMLOutputContextClassClass |
After instantiating an output format object, an application can set the output format parameters and use the object as an argument to the ExecuteBatch method of the LogQuery object.
Methods
The Output Format objects do not expose methods.
Properties
The Output Format objects expose read/write properties with the same names and capitalization as the parameters accepted by the corresponding Log Parser output format.For example, the MSUtil.LogQuery.CSVOutputFormat output format object exposes a "headers" property that controls the headers parameter of the CSV output format.
The value type accepted and returned by an output format object property depends on the nature of the values that can be specified for the output format parameter, as described by the following table:
Parameter values | Property value type | JScript Example |
---|---|---|
"ON"/"OFF" values | Boolean | oCSVOutputFormat.tabs = true; |
Enumeration values (e.g. "ON"/"OFF"/"AUTO") | String | oCSVOutputFormat.oDQuotes = "OFF"; |
String values | String | oCSVOutputFormat.oTsFormat = "yyyy-MM-dd"; |
Numeric values | Number | oCSVOutputFormat.oCodepage = -1; |
Examples
JScript example:
var oLogQuery = new ActiveXObject("MSUtil.LogQuery"); // Create EVT Input Format object var oEVTInputFormat = new ActiveXObject("MSUtil.LogQuery.EventLogInputFormat"); // Create CSV Output Format object var oCSVOutputFormat = new ActiveXObject("MSUtil.LogQuery.CSVOutputFormat"); // Set output format parameters oCSVOutputFormat.tabs = true; oCSVOutputFormat.oDQuotes = "OFF"; oCSVOutputFormat.oTsFormat = "yyyy-MM-dd"; oCSVOutputFormat.oCodepage = -1; // Create query text var strQuery = "SELECT TimeGenerated, Message INTO Output.csv FROM System"; // Execute query oLogQuery.ExecuteBatch( strQuery, oEVTInputFormat, oCSVOutputFormat );VBScript example:
Dim oLogQuery Dim oEVTInputFormat Dim oCSVOutputFormat Dim strQuery Dim oRecordSet Set oLogQuery = CreateObject("MSUtil.LogQuery") ' Create EVT Input Format object Set oEVTInputFormat = CreateObject("MSUtil.LogQuery.EventLogInputFormat") ' Create CSV Output Format object Set oCSVOutputFormat = CreateObject("MSUtil.LogQuery.CSVOutputFormat") ' Set output format parameters oCSVOutputFormat.tabs = True oCSVOutputFormat.oDQuotes = "OFF" oCSVOutputFormat.oTsFormat = "yyyy-MM-dd" oCSVOutputFormat.oCodepage = -1 ' Create query text strQuery = "SELECT TimeGenerated, Message INTO Output.csv FROM System" ' Execute query oLogQuery.ExecuteBatch strQuery, oEVTInputFormat, oCSVOutputFormat
See also:
LogQuery ObjectInput Format Objects
Log Parser COM API Overview
C# Example