<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Robert McMurray's Blog [MSFT] : LogParser</title><link>http://blogs.msdn.com/robert_mcmurray/archive/tags/LogParser/default.aspx</link><description>Tags: LogParser</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Using LogParser with FTP 7.x Sessions</title><link>http://blogs.msdn.com/robert_mcmurray/archive/2009/06/11/using-logparser-with-ftp-7-x-sessions.aspx</link><pubDate>Fri, 12 Jun 2009 05:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9728698</guid><dc:creator>robert_mcmurray</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/robert_mcmurray/comments/9728698.aspx</comments><wfw:commentRss>http://blogs.msdn.com/robert_mcmurray/commentrss.aspx?PostID=9728698</wfw:commentRss><description>&lt;P&gt;One of the great features that we added to our W3C logging enhancements in FTP 7.0 and FTP 7.5 is the ability to track unique sessions, which are represented by GUIDs in a field that is named &lt;I&gt;&lt;B&gt;x-session&lt;/B&gt;&lt;/I&gt;. Because of this addition, you can do some interesting things with LogParser when analyzing your FTP logs.&lt;/P&gt;
&lt;P&gt;The purpose of today's blog is to show a couple of the scripts that I use to analyze some of the session-based information that I'm interested in from time to time.&lt;/P&gt;
&lt;H3&gt;Using LogParser to Count FTP Sessions&lt;/H3&gt;
&lt;P&gt;Since the new FTP service tracks unique sessions, it is now possible to generate reports that show the number of unique FTP sessions you served by day. The following batch file accomplishes this in two parts: first it creates a temporary tab-separated-value file that contains the unique sessions by day, then it calculates the number of sessions by day and writes the totals to a tab-separated-value file that is named &lt;I&gt;Sessions.tsv&lt;/I&gt;, which you can open using an application like Microsoft Excel.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;TT&gt;@echo off&lt;BR&gt;&lt;BR&gt;set LOGPATTERN=u_ex*.log&lt;BR&gt;&lt;BR&gt;logparser.exe "SELECT DISTINCT date,x-session INTO '%~n0.tmp' from %LOGPATTERN%" -i:w3c -o:tsv -headers:ON&lt;BR&gt;&lt;BR&gt;if exist "%~n0.tmp" (&lt;BR&gt;logparser.exe "SELECT date,COUNT(x-session) AS sessions INTO sessions.tsv FROM '%~n0.tmp' GROUP BY date" -i:tsv -o:tsv -headers:ON&lt;BR&gt;del "%~n0.tmp"&lt;BR&gt;)&lt;BR&gt;&lt;BR&gt;set LOGPATTERN=&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;H3&gt;Using LogParser to Split FTP Log Files into Unique Session Activity Logs&lt;/H3&gt;
&lt;P&gt;I use the following script when I am testing various FTP scenarios that will split my FTP log files into individual log files that are named after the GUID for each session. (&lt;B&gt;Note&lt;/B&gt;: Please bear in mind, this may generate a lot of log files, so use it sparingly!) You can then analyze the resulting log files to see the list of client activity that was unique to each session.&lt;/P&gt;
&lt;P&gt;This script accomplishes its objective in two parts: first it creates a temporary tab-separated-value file with the list of unique session IDs, then it loops through each session ID and creates a W3C log file for each session's activity.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;TT&gt;@echo off&lt;BR&gt;&lt;BR&gt;set LOGPATTERN=u_ex*.log&lt;BR&gt;&lt;BR&gt;logparser.exe "select distinct x-session into '%~n0.tmp' from '%LOGPATTERN%'" -i:w3c -o:tsv -headers:off &lt;BR&gt;&lt;BR&gt;if exist "%~n0.tmp" (&lt;BR&gt;for /f "delims=|" %%a in (%~n0.tmp) do (&lt;BR&gt;logparser.exe "select date,time,c-ip,cs-username,s-ip,s-port,cs-method,cs-uri-stem,sc-status,sc-win32-status,sc-substatus,x-session,x-fullpath into '%%a.log' from '%LOGPATTERN%' where x-session='%%a' order by date,time" -i:w3c -o:w3c&lt;BR&gt;)&lt;BR&gt;del "%~n0.tmp"&lt;BR&gt;)&lt;BR&gt;&lt;BR&gt;set LOGPATTERN=&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That about does it for today - I hope this helps!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9728698" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/robert_mcmurray/archive/tags/FTP/default.aspx">FTP</category><category domain="http://blogs.msdn.com/robert_mcmurray/archive/tags/LogParser/default.aspx">LogParser</category></item><item><title>Data Mining UrlScan 3.0 Logs using LogParser 2.2</title><link>http://blogs.msdn.com/robert_mcmurray/archive/2008/09/10/data-mining-urlscan-3-0-logs-using-logparser-2-2.aspx</link><pubDate>Wed, 10 Sep 2008 23:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8941852</guid><dc:creator>robert_mcmurray</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/robert_mcmurray/comments/8941852.aspx</comments><wfw:commentRss>http://blogs.msdn.com/robert_mcmurray/commentrss.aspx?PostID=8941852</wfw:commentRss><description>&lt;P style="FONT-SIZE: 10pt"&gt;We released a new version of &lt;A href="http://learn.iis.net/page.aspx/473/" target=_blank mce_href="http://learn.iis.net/page.aspx/473/"&gt;UrlScan&lt;/A&gt; recently, and one of the great new features in this version is log files that conform to the &lt;A href="http://www.w3.org/TR/WD-logfile" target=_blank mce_href="http://www.w3.org/TR/WD-logfile"&gt;W3C Extended Log File Format&lt;/A&gt;. What this means to administrators is that they can now parse their UrlScan activity using almost any common log utilities, including Microsoft's &lt;A href="http://www.iis.net/go/1287" target=_blank mce_href="http://www.iis.net/go/1287"&gt;LogParser 2.2&lt;/A&gt; utility. For anyone that hasn't heard of LogParser, this is a freeware utility from Microsoft that allows you to write SQL-style queries to extract useful information. Eventually I'd like for the following information to show up on the &lt;A class="" href="http://learn.iis.net/" target=_blank mce_href="http://learn.iis.net/"&gt;http://learn.iis.net/&lt;/A&gt; web site, but for now I'd like everyone to at least have access to the information.&lt;/P&gt;
&lt;HR&gt;

&lt;H2 style="FONT-SIZE: 15pt; COLOR: #000033"&gt;Getting Started&lt;/H2&gt;
&lt;H3 style="FONT-SIZE: 14pt; COLOR: #003300"&gt;Downloading and Installing UrlScan and LogParser&lt;/H3&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;The download locations for UrlScan are listed in the "Getting UrlScan" section of the following topic: &lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;A href="http://learn.iis.net/page.aspx/473/" mce_href="http://learn.iis.net/page.aspx/473/"&gt;http://learn.iis.net/page.aspx/473/&lt;/A&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;I&gt;&lt;B&gt;&lt;SMALL&gt;Note&lt;/B&gt;: There are separate downloads for 32-bit and 64-bit Windows.&lt;/SMALL&gt;&lt;/I&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;LogParser is available from the following URL: &lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;A href="http://www.iis.net/go/1287" mce_href="http://www.iis.net/go/1287"&gt;http://www.iis.net/go/1287&lt;/A&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;I&gt;&lt;B&gt;&lt;SMALL&gt;Note&lt;/B&gt;: It's a 32-bit application, but you can use it on a 64-bit Windows system.&lt;/SMALL&gt;&lt;/I&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;While it's not essential, copying Logparser.exe to a folder in your PATH will allow you to run LogParser from any folder on your system.&lt;/P&gt;
&lt;H3 style="FONT-SIZE: 14pt; COLOR: #003300"&gt;UrlScan Log Files&lt;/H3&gt;
&lt;H4 style="FONT-SIZE: 13pt; COLOR: #333300"&gt;Locating your UrlScan Log Files&lt;/H4&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;By default UrlScan installs to %WinDir%\System32\Inetsrv\urlscan, and this is where your Urlscan.ini file should be located. (If you installed to a different location, you would need to locate your installation by searching for your Urlscan.ini file.) In the &lt;B&gt;[Options]&lt;/B&gt; section of the Urlscan.ini file you should see an entry for &lt;B&gt;LoggingDirectory&lt;/B&gt; that is set "Logs" by default, which means that your default directory for UrlScan log files is %WinDir%\System32\Inetsrv\urlscan\Logs.&lt;/P&gt;
&lt;H4 style="FONT-SIZE: 13pt; COLOR: #333300"&gt;Log File Names&lt;/H4&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;UrlScan log files are named using the following syntax:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;TT&gt;urlscan.mmddyy.log&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;Where:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=3 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;mm&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;=&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;Month&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;dd&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;=&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;Day&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;yy&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;=&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;Year&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;
&lt;H4 style="FONT-SIZE: 13pt; COLOR: #333300"&gt;Log File Fields&lt;/H4&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;The following table lists the fields that are available:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;TABLE class="" style="BORDER-COLLAPSE: collapse" cellSpacing=1 borderColorDark=#000000 cellPadding=2 width=500 borderColorLight=#000000 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;Field&lt;/TH&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;Description&lt;/TH&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;Date &lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;Request date in YYYY-MM-DD format&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;Time &lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;Request time in UTC time&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;c-ip&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;IP address of the client that made the request&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;s-siteid&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;ID of the web site that received the request&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;cs-method&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;HTTP method for the request&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;cs-uri&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;URL for the request&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;x-action&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;Action taken; for example: 
&lt;TABLE class="" cellSpacing=0 cellPadding=3 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;Logged and allowed&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;Rejected&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;x-reason&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;Reason for action; for example: 
&lt;TABLE class="" cellSpacing=0 cellPadding=3 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;a request header was too long&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;content length too long&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;disallowed header detected&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;disallowed query string sequence detected&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;disallowed url sequence detected&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;dot in path detected&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;extension not allowed&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;failed urlscan rules&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;high bit character detected&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;query string too long&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;second pass normalization failure&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;url too long&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;verb not allowed&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;x-context&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;Part of request that triggered the action; for example: 
&lt;TABLE class="" cellSpacing=0 cellPadding=3 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;Content-Length&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;file extension&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;HTTP_ALL_RAW&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;HTTP method&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;query string&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;request headers&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left width=25&gt;-&lt;/TH&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;URL&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;cs-data&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;The request data that triggered the action.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top noWrap align=left&gt;x-control&lt;/TD&gt;
&lt;TD class="" style="FONT-SIZE: 10pt" vAlign=top align=left&gt;Config control data that caused the trigger.&amp;nbsp; For example, if a request was rejected because of a deny string from a UrlScan rule, the specific deny string will be listed.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;
&lt;HR&gt;

&lt;H2 style="FONT-SIZE: 15pt; COLOR: #000033"&gt;Querying Data&lt;/H2&gt;
&lt;H3 style="FONT-SIZE: 14pt; COLOR: #003300"&gt;Simple Queries&lt;/H3&gt;
&lt;H4 style="FONT-SIZE: 13pt; COLOR: #333300"&gt;Selecting Everything&lt;/H4&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;The simplest (and least useful) query that you can issue is the following, which is listed here just to get us started:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;TT&gt;logparser.exe "SELECT * FROM urlscan.*.log" -i:w3c&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;Let's analyze what this query does:&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Selects all fields ("SELECT *") from all records in all log files ("FROM urlscan.*.log")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Specifies the log file input type as "W3C Format" ("-i:w3c")&lt;/LI&gt;&lt;/OL&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Note&lt;/B&gt;: Specifying the input file format as "W3C Format" is essential - without that step you would not be able to parse your UrlScan logs.&lt;/P&gt;
&lt;H4 style="FONT-SIZE: 13pt; COLOR: #333300"&gt;Selecting Specific Fields to Query&lt;/H4&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;You can restrict the amount of data that you see by specifying which fields to return:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;TT&gt;logparser.exe "SELECT date,time,c-ip,x-action FROM urlscan.*.log" -i:w3c&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;Here's what this query does:&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Selects only four specific fields ("SELECT date,time,c-ip,x-action") from all records in all log files ("FROM urlscan.*.log")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Specifies the log file input type as "W3C Format" ("-i:w3c")&lt;/LI&gt;&lt;/OL&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;This allows you to greatly reduce the amount of information that you see in your results.&lt;/P&gt;
&lt;H4 style="FONT-SIZE: 13pt; COLOR: #333300"&gt;Exporting Logs into a Different Format&lt;/H4&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;As mentioned earlier, selecting all of the records in all of your logs is probably not all that helpful, unless you were interested in parsing your UrlScan information using another application, like Microsoft Excel, Microsoft Access, SQL Server, etc. In which case, you might want to export all of your data into a comma-delimited file like the following example:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;TT&gt;logparser.exe "SELECT * INTO UrlScan.csv FROM urlscan.*.log" -i:w3c -o:csv&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;Here's what this query does:&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Selects all fields ("SELECT *") from all records in all log files ("FROM urlscan.*.log")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Inserts from all records into a comma-delimited file ("INTO UrlScan.csv")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Specifies the input file type as "W3C Format" ("-i:w3c")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Specifies the output file type as "CSV Format" ("-o:csv")&lt;/LI&gt;&lt;/OL&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;You could just as easily export into a tab-separated file using the following syntax:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;TT&gt;logparser.exe "SELECT * INTO UrlScan.tsv FROM urlscan.*.log" -i:w3c -o:tsv&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;H3 style="FONT-SIZE: 14pt; COLOR: #003300"&gt;Filtering Queries&lt;/H3&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;One of the great things about LogParser and SQL queries in general is that you can filter the amount of data that you see by specifying criteria using a WHERE clause. The following &lt;/P&gt;
&lt;H4 style="FONT-SIZE: 13pt; COLOR: #333300"&gt;Filtering based on IP Address&lt;/H4&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;For example, to see all of the requests from a specific client IP address, you could use the following syntax:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;TT&gt;logparser.exe "SELECT * FROM urlscan.*.log WHERE c-ip='192.168.1.1'" -i:w3c&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;Here's what this query does:&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Selects all fields ("SELECT *") from all records in all log files ("FROM urlscan.*.log")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Filters the results based on a specific client IP address ("WHERE c-ip='192.168.1.1'")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Specifies the input file type as "W3C Format" ("-i:w3c")&lt;/LI&gt;&lt;/OL&gt;
&lt;H4 style="FONT-SIZE: 13pt; COLOR: #333300"&gt;Filtering based on UrlScan Action&lt;/H4&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;You can also filter based on UrlScan rejections using the following syntax:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;TT&gt;logparser.exe "SELECT * FROM urlscan.*.log WHERE x-action='Rejected'" -i:w3c&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;Here's what this query does:&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Selects all fields ("SELECT *") from all records in all log files ("FROM urlscan.*.log")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Filters the results where UrlScan rejected the request ("WHERE x-action='Rejected'")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Specifies the input file type as "W3C Format" ("-i:w3c")&lt;/LI&gt;&lt;/OL&gt;
&lt;H4 style="FONT-SIZE: 13pt; COLOR: #333300"&gt;Filtering based on Uniqueness&lt;/H4&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;You can filter the amount of data that you see by specifying which fields to return and grouping the data based on uniqueness. This is done by adding the DISTINCT clause as seen in the following syntax:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;TT&gt;logparser "SELECT DISTINCT c-ip FROM urlscan.*.log" -i:w3c&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;Here's what this query does:&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Selects only the unique client IP addresses ("SELECT DISTINCT c-ip") from all records in all log files ("FROM urlscan.*.log")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Specifies the input file type as "W3C Format" ("-i:w3c")&lt;/LI&gt;&lt;/OL&gt;
&lt;H3 style="FONT-SIZE: 14pt; COLOR: #003300"&gt;Grouping, Tabulating, and Sorting Queries&lt;/H3&gt;
&lt;H4 style="FONT-SIZE: 13pt; COLOR: #333300"&gt;Counting Requests by Fields&lt;/H4&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;Another great feature of SQL-style queries is the ability to tabulate data. The following example shows how retrieve a count of requests based on the client IP address:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;TT&gt;logparser.exe "SELECT c-ip, COUNT(*) FROM urlscan.*.log GROUP BY c-ip" -i:w3c&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;Here's what this query does:&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Selects only the client IP address and request count ("SELECT c-ip, COUNT(*)") from all records in all log files ("FROM urlscan.*.log")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Groups the request count based on the client IP address ("GROUP BY c-ip")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Specifies the input file type as "W3C Format" ("-i:w3c")&lt;/LI&gt;&lt;/OL&gt;
&lt;H4 style="FONT-SIZE: 13pt; COLOR: #333300"&gt;Sorting Data by Fields&lt;/H4&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;You can reorder your results into something more useful using the ORDER BY clause, as illustrated in the following example:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;TT&gt;logparser.exe "SELECT x-action,x-reason,c-ip,cs-uri FROM urlscan.*.log ORDER BY x-action,x-reason" -i:w3c&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;Here's what this query does:&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Selects four specific fields ("SELECT x-action,x-reason,c-ip,cs-uri") from all records in all log files ("FROM urlscan.*.log")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Sorts the data in ascending order based on the UrlScan action and reason for the action ("ORDER BY x-action,x-reason")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Specifies the input file type as "W3C Format" ("-i:w3c")&lt;/LI&gt;&lt;/OL&gt;
&lt;HR&gt;

&lt;H2 style="FONT-SIZE: 15pt; COLOR: #000033"&gt;Putting it All Together&lt;/H2&gt;
&lt;H4 style="FONT-SIZE: 13pt; COLOR: #333300"&gt;Counting Requests by Client IP and Sorting Data by Request Count&lt;/H4&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;Starting with the request count query from a previous example, you can rename the request count field to something more useful using the AS clause, as illustrated in the following example:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;TT&gt;logparser.exe "SELECT c-ip, COUNT(*) AS c-request-count FROM urlscan.*.log GROUP BY c-ip" -i:w3c&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;This helps reorder the data based on the count, as shown in the following example:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;TT&gt;logparser.exe "SELECT c-ip, COUNT(*) AS c-request-count FROM urlscan.*.log GROUP BY c-ip ORDER BY c-request-count DESC" -i:w3c&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;Here's what this query does:&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Selects only the client IP address and request count ("SELECT c-ip, COUNT(*)") from all records in all log files ("FROM urlscan.*.log")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Groups the request count based on the client IP address ("GROUP BY c-ip")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Sorts the data in descending order based on the request count ("ORDER BY c-request-count DESC")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Specifies the input file type as "W3C Format" ("-i:w3c")&lt;/LI&gt;&lt;/OL&gt;
&lt;H4 style="FONT-SIZE: 13pt; COLOR: #333300"&gt;Counting Rejected Requests based on the Reason for Rejections&lt;/H4&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;While somewhat similar to the previous example, the following syntax will filter the results based on rejections and count the number of times that each reason occurs:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;TT&gt;logparser.exe "SELECT x-reason, COUNT(*) AS c-request-count FROM urlscan.*.log WHERE x-action='Rejected' GROUP BY x-reason ORDER BY c-request-count DESC" -i:w3c&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;Here's what this query does:&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Selects only the reason and request count ("SELECT x-reason, COUNT(*)") from all records in all log files ("FROM urlscan.*.log")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Filters the results based on rejections ("WHERE x-action='Rejected'")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Groups the request count based on the reason ("GROUP BY x-reason")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Sorts the data in descending order based on the request count ("ORDER BY c-request-count DESC")&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Specifies the input file type as "W3C Format" ("-i:w3c")&lt;/LI&gt;&lt;/OL&gt;
&lt;H4 style="FONT-SIZE: 13pt; COLOR: #333300"&gt;Splitting Requests into Separate Log Files based on Site ID&lt;/H4&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;UrlScan writes all log entries to a common log file, but you may want to see your data separated by site. The following example splits your UrlScan logs into separate files by site by creating unique log files that are named for each site ID. This example is a little more complex than previous examples, and is written as a batch file.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;&lt;TT&gt;logparser.exe "SELECT DISTINCT s-siteid INTO siteids.tsv FROM urlscan.*.log" -i:W3C -o:tsv -headers:off&lt;BR&gt;&lt;BR&gt;for /f %%a in (siteids.tsv) do (&lt;BR&gt;&amp;nbsp;&amp;nbsp; logparser.exe "SELECT * INTO W3SVC%%a.log FROM urlscan.*.log WHERE s-siteid='%%a' ORDER BY date,time" -i:W3C -o:w3c&lt;BR&gt;)&lt;/TT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P style="FONT-SIZE: 10pt"&gt;Here's what this batch file does:&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Creates a tab-separated file that contains a list of unique site IDs&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Creates a loop to step through the tab-separated file containing the site IDs&lt;/LI&gt;
&lt;LI style="FONT-SIZE: 10pt"&gt;Selects all fields for the specific site ID and creates a new W3C format file for each site&lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8941852" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/robert_mcmurray/archive/tags/IIS+Topics/default.aspx">IIS Topics</category><category domain="http://blogs.msdn.com/robert_mcmurray/archive/tags/LogParser/default.aspx">LogParser</category></item></channel></rss>