Most efficient way to tail a rolling log file in Windows

Question:

What is the most efficient way to tail log files that are rolled over when they get to a certain size. Some app log files can get quite large, 100+ MB.

For example:
Tailing “file.log”.

After it gets to 25MB, that file is renamed (“file.log.1”). A new blank fresh “file.log” is created to replace it.

One option I found is: PowerShell cmdlet Get-Content

Anyone know if it is smart enough to know that a file has rolled over (re-named, re-created) as such no line is missed during the roll over?

Or if some checks are needed. If so can I get some ideas please.

Any better options for Windows?

Thanks.

Answer:

You can use below Powershell command:

Source:

Most efficient way to tail a rolling log file in Windows by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply