Public/ps1/Log/Move-ApprxrLogFile.ps1
|
<#
.SYNOPSIS Rotates the current Apprxr log file by renaming it with a timestamp extension. .DESCRIPTION The Move-ApprxrLogFile function renames the current log file by appending a Unix timestamp to its name. This is used for log rotation, allowing new log files to be created while retaining old logs for reference or retention policies. .EXAMPLE Move-ApprxrLogFile .NOTES Called by log management functions to rotate logs when retention or age thresholds are met. #> function Move-ApprxrLogFile { # Only proceed if log management configuration is available if ($LogManagement) { # Generate a Unix timestamp for the rotated log file name $extension = [int](Get-Date -UFormat %s -Millisecond 0) $logFile = $LogManagement.LogFolder # Rename (rotate) the log file by appending the timestamp Move-Item $logFile ($LogManagement.LogFolder+"_"+$extension) } } |