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
1 2 |
gc file.log -wait -tail 1 |
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:
1 2 |
get-content {file_name} -tail 10 -wait |