LogParser and SharePoint logs

Normally I use ULSViewer in order to search SharePoint log files. I had a situation where I needed to search for several GB of log files which ULS viewer cant handle without to much lag on my machine.

An alternative for parsing SharePoint logfiles is good old LogParser which enables to do SQL like search/filtering/grouping to any log file even windows event log is supported.

I prefer to have a seperat file which contain my query. Create a new file called queryfile.txt. Paste the snippet from below. Remember to put the coloumns in [ ].

select * from c:\pathtosharepointlogs\*.* where [Message] like '%criteria%'


Start LogParser using the new short installed but LogParser. I prefer to pipe the output to an textfile but this is optional.


LogParser.exe -i:tsv -headerRow:on file:sql.txt > results.txt


This was just a basic start but the SQL can be complex if need be. It can be a good tool for create statistics using IIS logs for instance. Here you can find more advanced usages of LogParser http://technet.microsoft.com/en-us/library/ee692659.aspx


UPDATE


A better approach instead of using > piping is to change the SQL state to this


select * into results.txt from C:\pathtosharepointlogs\*.log where [Message] like '%criteria%'


LogParser command

 


LogParser.exe -i:tsv -headerRow:on file:sql.txt 


Etiketter: , ,