Periodic log file parsing
hello everyone,
here challenge. need parse log file periodically. not have code trying figure out how that. here case;
1- log file ( get-content c:\logs\test.log )
2- each matching line something ( get-content c:\logs\test.log | select-string "failed123" | foreach-object )
3- remember last processed line , record it. ( maybe output line number temporary log file)
4- exit powershell
5- 5 minutes later start process log file again , start last processed line ( maybe read content of temp log file , line number start processing line number again )
6- each matching line again.
7- remember last processed line , record it.
8- exit powershell.
another thing if log file gets rotated, need powershell process log file beginning.
i hope explained well.
any thoughts, ideas , input appreciated.
thanks you.
orhan taskin
couple of questions:
is every line in log file unique, or there multiple identical events (ie same timestamp , event detail)?
how files named when log rotates?
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Windows Server > Windows PowerShell
Comments
Post a Comment