Find 404 errors using Log Parser
Note: This article was written using Log Parser 2.2. Therefore, while it may work for a different version, it may not.
The following code will generate a listing of calls that generated a 404 error.
logparser "SELECT cs-uri-stem, cs-uri-query, date, sc-status, cs(Referer) INTO 404report.txt FROM ex.log WHERE sc-status = 404 ORDER BY date, cs-uri-stem, cs-uri-query"
This assumes that you've currently got a command line open in the folder containing your IIS logs, and that you are logging the above information, as well as that logparser is setup in your PATH line.
A file called '404report.txt' will be generated in the folder containing your log files, which will list the above five fields. It's possible to generate a count instead, but I have no done so above.
Here's one that generates a count with pages and referers listed, of 404 pages.
logparser "SELECT cs-uri-stem AS page, cs(Referer) AS referer, count() AS hits INTO 404report.txt FROM ex*.log WHERE sc-status = 404 GROUP BY page, referer ORDER BY page"
All-in-all, I'm pretty impressed by this tool, once you have time to actually work with it.
Updated both codes to export to 404report.txt, instead of just report.txt.
Support This Site
If my blog was helpful to you, then please consider visiting my Amazon Wishlist.