Rename logs at certain size
Most systems have built in the options to automatically switch to a new log file when it reaches a certain size, but some systems do not have that option.
Then it can be handy to be able to do that, i had that need and wrote this script.
You can monitor several log files at the same time, just add or remove
$LogArray parameters to match what logs you want to monitor and the set the
$LogSize to your preferred size in
The script will rename the files with original name and a timestamp, the script honors the file extension as well.
The time format in the script is
Min and is in 24H format, if you wish to change that the look at row
55 in the script and search the internet for
Powershell Get-Date Format to see what options exists.
If our current date and time was
log1.logwould be renamed to
log2.txtwould be ranamed to
Important to note is that it will rename the existing file and the system creating the log files must be able to create a new one when ever it need to write data to it.
The script in it's full glory.