Differences

This shows you the differences between two versions of the page.

Link to this comparison view

log_tail_with_powershell_en [2019/08/08 15:24] (current)
Line 1: Line 1:
 +====== Log Tail with PowerShell ======
 +
 +I needed a way to monitor the output of the Dynamics CRM trace log file and stupidly went <​nowiki>​GoogleBing-ing</​nowiki>​ for a "​tail"​ equivalent application for Windows. I should have known to turn to trusted <​nowiki>​PowerShell</​nowiki>​!
 +
 +Get the last 10 lines of a log file:
 +<sxh ps>
 +Get-Content mylogfile.log -Tail 10
 +</​sxh>​
 +
 +Get the first 20 lines of a log file:
 +<sxh ps>
 +Get-Content mylogfile.log -Head 20
 +</​sxh>​
 +Monitor a live log file:
 +<sxh ps>
 +Get-Content mylogfile.log -Wait
 +</​sxh>​
 +Monitor a live log file but only print the last 5 lines when starting up:
 +<sxh ps>
 +Get-Content mylogfile.log -Wait -Tail 5
 +</​sxh>​
 +
 +
 +===== References =====
 +  - http://​devbeard.com/​log-tail-with-powershell/​