Get live log updates in PowerShell
This post is over a year old, the information may no longer be up to date.
This post was migrated from an old custom CMS. Some data may not look accurate.
Tutorial • 04 May 2020
I frequently find myself needing to review log files on a ‘live’ basis, and although there are applications out there that do this I work on different servers every day so installing an application to do this seems messy.
I found out last year that you can actually live view a log via PowerShell, so that when the file gets updated it’ll obviously show you the new data in the PowerShell window instantly.
Below is a really basic example of how you can do this, I might make it into a standalone ps1 one day but this works as-is for the time being and is super quick to do.
1 2 CD "c:\program files\product\logs\" Get-Content "logfile.log" -wait
Note: On occasion the tail will freeze and make it look like the file hasn’t been updated, this can be fixed by doing CTRL+C twice in a row and it will start updating the tail again.