
You must specify at least 1 or an error will occur: Get-Content "C:\Temp\debugtest. Tail (or its alias -Last) will output the last x number of lines in the file. The Log Monitor tool consists of two primary elements: LogMonitor.exe and LogMonitorConfig.json. If we are only interested in lines being added since running the command we can use a parameter called -Tail.

This will write out the contents of the file and keep the file open, updating the terminal with the lines being added:Īs stated, Get-Command will output the entire contents of the file to the terminal by default. The benefits of log file monitoring include: Monitor log data for any event or pattern Identify errors for any failure Improved security A log file maintains a record and timestamp of events that occur in an application. With the above file creator script running, I’m going to open a new PowerShell terminal and run the following command: Get-Content "C:\Temp\debugtest.txt" -Wait The log file monitor tracks errors in logs generated from applications on Windows and Linux servers.
A LOG FILE MONITOR PLUS
The above script will write the string “Line ” plus the value of variable $i to a file called C:\Temp\debugtest.txt 100 times, pausing for 1 second after every write. To demonstrate this, lets first create a small script to output lines to a file, which we can then monitor: For ($i = 1 $i -le 100 $i++)Īdd-Content -Path "C:\Temp\debugtest.txt" -Value ('Line ' -f $i) It will keep the file open until we either close the terminal or type Ctrl+C to manually terminate execution. The Get-Content cmdlet has a parameter called -Wait which will keep the file open and write out any lines that are added to the file. For example, you can monitor the MySQL slow.

The Get-Content cmdlet is used to write the contents of a file to the terminal: PS C:\WINDOWS\system32> Get-Content "C:\Temp\debugtest.txt" LogicMonitor lets you monitor log files generated by your OS or applications such as MySQL, Tomcat, and so on. To aid setup and debug scenarios for applications that output data to files, you can live monitor log files with PowerShell.
