Get the SessionID in IIS7 LogParser Query on Site Using SSL

iis-7logparser

Anyone know how to obtain the SessionID/ASPNET_SESSIONID using a LogParser query? FYI, the site I'm querying uses SSL. Currently, my query is

SELECT * FROM 'C:\inetpub\logs\LogFiles\W3SVC6\*.log'
where cs-uri-stem like '%.doc' OR cs-uri-stem like '%.docx' AND date >= '2012-07-01'

Best Answer

How about this:

SELECT 
 EXTRACT_VALUE(REPLACE_str(cs(Cookie),';+','&'), 'ASP.NET_SessionId', '&') AS Cky,
 <other_column_names> 
FROM 'C:\inetpub\logs\LogFiles\W3SVC6\*.log'
WHERE cs-uri-stem like '%.doc' OR cs-uri-stem LIKE'%.docx' AND date >= '2012-07-01'

Unlike SQL, You have to specify the columns you're interested in explicitly instead of adding a * column wildcard (i.e. the <other_column_names> placeholder in the query above).

You also need to make sure that IIS is configured to log cookies as well in your logging settings (assuming you're using the W3C logging format):

enter image description here