Reputation: 11
Log files are available inside the 1500 folders.
D:\temp\output\BG Output_Last_0001\log.txt
D:\temp\output\BG Output_Last_0002\log.txt
D:\temp\output\BG Output_Last_0003\log.txt
D:\temp\output\BG Output_Last_0004\log.txt
D:\temp\output\BG Output_Last_0005\log.txt
.
.
I can get the output of parsing a single log file using the below command.
C:\Program Files (x86)\Log Parser 2.2>LogParser -i:TSV "select MIN(Datetime) AS StartTime from 'D:\temp\output\log_0001\log.txt'" -o:datagrid
What I tried:
I tried the below command to parse using the * symbol in Log Parser
C:\Program Files (x86)\Log Parser 2.2>LogParser -i:TSV "select MIN(Datetime) AS StartTime from 'D:\temp\output\*\log.txt'" -o:datagrid
D:\temp\output\*\log.txt
Can someone help how to parse the log from the multiple folders?
Upvotes: 1
Views: 744
Reputation: 189
You need to use the PowerShell script
Conceptual script, I didn't try it out:
$IISLogPath = 'D:\temp\output\'
$logPaths = Get-ChildItem -Path $IISLogPath -Recurse
$logPaths = "$($logPaths -join ",")" <-- join multiple files into one-liner
$logParserPath = "C:\Program Files (x86)\Log Parser 2.2\LogParser.exe"
$query =
@"
SELECT select MIN(TO_LOCALTIME(TO_TIMESTAMP(date, time)))
FROM '$logPaths'
"@
& $logParserPath -i:IISW3C $query -stats:OFF -rtp:-1
}
Upvotes: 0