Freigeben über


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

Comments

  • Anonymous
    October 01, 2006
    Or simpler:
    grep cache *.cs -S

    To get the same result
  • Anonymous
    October 01, 2006
    Cool. Thanks for sharing it.

    I wish we had "inbuilt" grep for windows. Having said that, I am blogging about Log parser and its scenarios mainly because I feel it is a really versatile and POWERFUL tool and can do much more than "find".

    Cheers,
    Rahul
  • Anonymous
    October 06, 2006
    Hmmm, I wonder if that's what gamespot.com's problem is. Every time I go there, it shows the username at the top of someone other than myself. Hitting the refresh button fixes it. Can't tell what tech they use though (e.g. asp.net, php, etc...)