Conversion Mode
In "Conversion Mode", Log Parser is used to execute built-in queries to convert log files between the following formats:
Conversion mode is activated by the "-c" switch.
The general syntax of commands in conversion mode is:
LogParser |
|
For more information on log file format conversions, refer to Converting File Formats.
- -i:<input_format>
-
Specifies the input format for the conversion.
The "-i:" switch is followed by the name of the selected input format, as in the following example:C:\>LogParser -c -i:IISW3C -o:IIS extend1.log inetsv1.log
Differently than Query Execution Mode, the input format specification is a mandatory argument for commands in conversion mode.
The specified input format name must be one of the input formats in the table above for which a conversion is supported. - -o:<output_format>
-
Specifies the output format for the conversion.
The "-o:" switch is followed by the name of the selected output format, as in the following example:C:\>LogParser -c -i:IISW3C -o:IIS extend1.log inetsv1.log
Differently than Query Execution Mode, the output format specification is a mandatory argument for commands in conversion mode.
The specified output format name must be one of the output formats in the table above for which a conversion is supported. - <from_entity>
-
Specifies the input file(s) to be converted.
This argument must conform to the <from_entity> syntax of the selected input format. For information on the syntax and interpretation of the <from_entity> values supported by each input format, refer to the Input Formats Reference.
If the argument contains spaces, it must be enclosed within double-quote characters ("), as in the following example:C:\>LogParser -c -i:IISW3C -o:IIS "extend1.log;, <1>" inetsv1.log
- <into_entity>
-
Specifies the conversion target output file.
This argument must conform to the <into_entity> syntax of the selected output format. For information on the syntax and interpretation of the <into_entity> values supported by each output format, refer to the Output Formats Reference.
If the argument contains spaces, it must be enclosed within double-quote characters ("), as in the following example:C:\>LogParser -c -i:IISW3C -o:IIS extend1.log "C:\My Folder\inetsv1.log"
- <where_clause>
-
Specifies an optional WHERE clause to perform
filtering on the input format entries.
The following example converts only the IISW3C log file entries that represent successful requests:C:\>LogParser -c -i:IISW3C -o:IIS extend1.log inetsv1.log "WHERE sc-status BETWEEN 200 AND 399"
- <input_format_options>
-
Specify values for input format parameters.
These are entered as switches with names matching the input format's parameter names, followed by a colon and by the value for the parameter, as in the following example:C:\>LogParser -c -i:IISW3C -o:IIS extend1.log inetsv1.log -iCodepage:932
For more information on input format parameters, refer to the Input Format Reference. - <output_format_options>
-
Specify values for output format parameters.
These are entered as switches with names matching the output format's parameter names, followed by a colon and by the value for the parameter, as in the following example:C:\>LogParser -c -i:IISW3C -o:IIS extend1.log inetsv1.log -fileMode:1
For more information on output format parameters, refer to the Output Format Reference. - -multiSite[:ON|OFF]
-
Specifies that an IIS Central Binary log file is to be converted to multiple
log files, one for each IIS Virtual Site.
This option is only available when the conversion is from the BIN input format, and when the specified <into-entity> contains one "*" wildcard enabling the Multiplex Ouput Mode. The wildcard will be replaced with the numeric identifiers of the IIS Virtual Sites that served the requests logged in the central binary log file.
The following example converts a single IIS Central Binary log file to different W3C log files, one for each IIS Virtual Site that served a request logged in the central binary log:C:\>LogParser -c -i:BIN -o:W3C raw1.ibl C:\NewLogs\W3SVC*\extend1.log -multiSite:ON
- <global_switches>
-
Global switches control overall behaviors of the command, such as error handling and
command statistics verbosity.
For more information on global switches, refer to the Global Switches Reference. - -queryInfo
-
Displays diagnostic information about the conversion command.
When "-queryInfo" is specified, the command is not executed, and the following diagnostic information is displayed to the console window:- The text of the conversion query, after being parsed and interpreted by the Log Parser SQL-Like engine core;
- Names of the input and output formats selected;
- Structure of the query output records, including field names and field data types.
The following example uses the "-queryInfo" switch to display diagnostic information about the specified conversion command:
C:\>LogParser -c -i:IISW3C -o:IIS extend1.log inetsv1.log -queryInfo
The output of this command is:Query: SELECT [c-ip], [cs-username], TO_DATE(TO_LOCALTIME(TO_TIMESTAMP([date], [time]))), TO_TIME(TO_LOCALTIME(TO_TIMESTAMP([date], [time]))), [s-sitename], [s-computername], [s-ip], [time-taken], [sc-bytes], [cs-bytes], [sc-status], [sc-win32-status], [cs-method], [cs-uri-stem], [cs-uri-query] INTO inetsv1.log FROM extend1.log Formats selected: Input format: IISW3C (IIS W3C Extended Log Format) Output format: IIS (IIS Log Format) Query fields: c-ip (S) cs-username (S) TO_DATE(TO_LOCALTIME(TO_TIMESTAMP(date, time))) (T) TO_TIME(TO_LOCALTIME(TO_TIMESTAMP(date, time))) (T) s-sitename (S) s-computername (S) s-ip (S) time-taken (I) sc-bytes (I) cs-bytes (I) sc-status (I) sc-win32-status (I) cs-method (S) cs-uri-stem (S) cs-uri-query (S)
See also:
Command-Line Operation ReferenceGlobal Switches Reference
Converting File Formats