ProgrammingWindows

Using Log Parser Studio to Get Request By Host Name

I am working on an application that accepts request for many different domain names, and sends back different content for each one. This means there is one log file for multiple logical sites, because they all run within the same instance of the web application.

To make diagnostics easier, I have enabled the “cs-host” column in IIS to log the host name in the log files.

The following log parser studio query will get you the number of requests for a given host name in log parser studio:

SELECT TOP 20
    cs-host, 
    COUNT(*) AS Total
FROM '[LOGFILEPATH]' 
GROUP BY cs-host
ORDER BY Total DESC

And this log parser studio query will get you the top URLs for that host:

SELECT TOP 20
    cs-uri-stem, 
    COUNT(*) AS Total, 
    MAX(time-taken) AS MaxTime, 
    AVG(time-taken) AS AvgTime,
    AVG(sc-bytes) AS AvgBytes
FROM '[LOGFILEPATH]' 
WHERE cs-host = 'example.com'
GROUP BY cs-uri-stem
ORDER BY Total DESC