Log files are dynamic and their content changes frequently in time. To monitor log files, their content should be watched when it changes. This tutorial demonstrates how to watch a log files in real time on Windows.
There is no built-in command on Windows that can be executed in Command Prompt (CMD) to monitor a text file for changes in real time. However, it can be achieved using PowerShell. Use the Get-Content
command with -Wait
parameter to watch a log files in real time. It continuously will display the new lines added to the file.
Get-Content log.txt -Wait
Command outputs the entire content of the file before outputting any extra lines that are added. However, it can be undesirable result for large files. The -Tail
parameter can show the last N lines of the file. The following command shows the last 10 lines of the file and waits for more:
Get-Content log.txt -Tail 10 -Wait
Leave a Comment
Cancel reply