Skip to content

Commit 9a42543

Browse files
committed
Fix: Fix copytruncate to work when another process has an read lock on the log file
Fixes #52
1 parent 6bb4ef4 commit 9a42543

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Log-Rotate/classes/New-LogObject.ps1

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ function New-LogObject {
2929
if ($copytruncate) {
3030
Write-Verbose "Truncating $my_fullname"
3131
if (!$WhatIf) {
32-
Clear-Content $my_fullname
32+
# Truncate the file
33+
[IO.File]::WriteAllText($my_fullname, '')
3334
}
3435
}else {
3536
Write-Verbose "Not truncating $my_fullname"

0 commit comments

Comments
 (0)