Language: PowerShell
Parsing error logs for asp.net errors.
param ([string]$computerName = (gc env:computername)) function GetExceptionType($type, $logEvent) { if ($type -ne "Error") { $logEvent.ReplacementStrings[17] } else { $rx = [regex]"Exception:.([0-9a-zA-Z].+)" $matches = $rx.match($logEvent.ReplacementStrings[0]) $matches.Groups[1].Value } } function GetException($type, $logEvent) { if ($type -ne "Error") { $logEvent.ReplacementStrings[18] } else { $rx = [regex]"Message:.([0-9a-zA-Z].+)" $matches = $rx.match($logEvent.ReplacementStrings[0]) $matches.Groups[1].Value } } get-eventlog -log application -ComputerName $computerName | ? { $_.Source -eq "ASP.NET 2.0.50727.0" } | ? { $_.EntryType -ne "Information" } | select ` Index, EntryType, TimeGenerated, ` @{Name="User"; Expression={$_.ReplacementStrings[22]}}, ` @{Name="Url"; Expression={truncate-string $_.ReplacementStrings[19] 60 }}, ` @{Name="Type"; Expression={GetExceptionType $_.EntryType $_ }}, ` @{Name="Exception"; Expression={GetException $_.EntryType $_ }}, ` @{Name="Details"; Expression={$_.ReplacementStrings[29]}}
Tags:
Comment:
Parsing error logs with PowerShell for specific types of ASP.NET sourced errors.
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

