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

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Windows 2016 RDS event 1306 Connection Broker Client failed to redirect the user... Error: NULL