Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using log parser to parse lot of logs in different folders

I recently started to use Log Parser with visual interface.

The logs that I want to parse come from IIS, and they are related to SharePoint. For example, I want to know how many people were visiting particular web pages, etc.

And it seems that IIS creates logs in different folders (I don't know why) and every day there is a new log file in a different folder.

So my question is, is it possible to approach all those files in different folders?

I know you can use From-clause, put different folders, but it is too difficult especially if in the future new folders are added. The goal is to create one script which would be executed.

So for example in a folder log named LogFIles, I have folders folder1, folder2, folder3, folder4, etc. and in each folder there are log files log1, log2, log 3, logN, etc.

So my query should be like this: Select * FROM path/LogFiles/*/*.log but the log parser doesn't accept it, so how to realize it?

like image 597
Alnedru Avatar asked Mar 08 '12 20:03

Alnedru


3 Answers

You can use the -recurse option when calling logparser.

For example:

logparser file:"query.sql" -i:IISW3C -o:CSV -recurse

where query.sql contains:

select *
from .\Logs\*.log

and in my current directory, there is a directory called "Logs" that contains multiple sub-directories, each containing log files. Such as:

\Logs\server1\W3SVC1
\Logs\server1\W3SVC2 
\Logs\server2\W3SVC1 
\Logs\server2\W3SVC2 
etc.
like image 115
densom Avatar answered Nov 13 '22 14:11

densom


You can merge the logs then query the merged log

what i have to do is

LogParser.exe -i:w3c "select * into E:\logs\merged.log from E:\logs\WEB35\*, E:\logs\WEB36\*, E:\logs\WEB37\*" -o:w3c
like image 45
James Taylor Avatar answered Nov 13 '22 14:11

James Taylor


I prefer powershell like this:

Select-String C:\Logs\diag\*.log -pattern "/sites/Very" | ?{$_.Line -match "Important"}
like image 1
Vlad Karassev Avatar answered Nov 13 '22 14:11

Vlad Karassev