Logparser Scenario 6:Searching files for culprits when you don't have Visual Studio on the Server.

This blog entry is a continuation of the KB Article https://support.microsoft.com/?id=910447.

Scenario 6: Searching for any specific text in all the files of a folder.

A small background of the problem
Recently we saw a very interesting problem. Users of a website were seeing other user's data in ASP.NET. There is cool blog entry about it by Jerry Orman https://blogs.msdn.com/jorman/archive/2005/11/22/495753.aspx where he talks about how to go about troubleshooting these issues. The Step 2 in his entry mentions about use of Caching. The customer didn't have much idea about the code (although it was present on the Server along with the aspx files) and was unable to answer whether they were using Caching or Static stuff in their code. We could have checked it easily, but they had about 2000+ pages in quite a few folders!!! Add to the problems, we didn't have VS installed on the server. The problem was now to see IF AT ALL they are using Caching or Static in their pages. I don't really trust Windows Search so I typically use Log Parser.

Answer: Open the Log Parser command window, and use the following command:
LOGPARSER "Select Text from 'C:\Code Folder\*.*' where Text like '%cache%'" -i:TEXTLINE

So, if you have any files containing the word Cache you will soon see something like this...

Text
-------------------
<%@OutputCache Duration="60" VaryByParam="none" %> 
<%@OutputCache Duration="60" VaryByParam="none" %> 

Statistics:
-----------
Elements processed: 234224
Elements output:    2
Execution time:     5.02 seconds

NOTE> This will only search in the Code Folder and not the subfolders.

If you don't find any line containing "%cache%" you will get something like...

Statistics:
-----------
Elements processed: 254442
Elements output:    0
Execution time:     5.88 seconds

In our case we were lucky, since we saw quite a few pages which had OutputCache directive. We discussed about it with the developers and came to know that among them there were a few ascx pages which were causing that issue. Anyways, that's a different story altogether :o)

To know more about how to troubleshoot these kind of issues, I would suggest you to go through Jerry's blog mentioned above.

Cheers,
Rahul