B
bay_dar
It seems there has got to be a better way to work with log files where
I want to keep 8 days of logs. For instance if I wanted to keep 80
days, this would be a horrible approach. How can I make this more
dynamic and efficient?
Const FTPOutputFile = "output-files.log"
Const FTPOutputFile1 = "output-files-1.log"
Const FTPOutputFile2 = "output-files-2.log"
Const FTPOutputFile3 = "output-files-3.log"
Const FTPOutputFile4 = "output-files-4.log"
Const FTPOutputFile5 = "output-files-5.log"
Const FTPOutputFile6 = "output-files-6.log"
Const FTPOutputFile7 = "output-files-7.log"
Sub Main()
'Do Stuff - gather log information
If a new day
RotateLogFiles()
End if
'Write to log....
End Sub
Sub RotateLogFiles()
'Delete Oldest Log
If objFSO.FileExists(FTPOutputFile7) = True Then
objFSO.DeleteFile(FTPOutputFile7)
End If
'Rotate logs
If objFSO.FileExists(FTPOutputFile6) = True Then
objFSO.MoveFile(FTPOutputFile6, FTPOutputFile7)
End If
If objFSO.FileExists(FTPOutputFile5) = True Then
objFSO.MoveFile(FTPOutputFile5, FTPOutputFile6)
End If
If objFSO.FileExists(FTPOutputFile4) = True Then
objFSO.MoveFile(FTPOutputFile4, FTPOutputFile5)
End If
If objFSO.FileExists(FTPOutputFile3) = True Then
objFSO.MoveFile(FTPOutputFile3, FTPOutputFile4)
End If
If objFSO.FileExists(FTPOutputFile2) = True Then
objFSO.MoveFile(FTPOutputFile2, FTPOutputFile3)
End If
If objFSO.FileExists(FTPOutputFile1) = True Then
objFSO.MoveFile(FTPOutputFile1, FTPOutputFile2)
End If
If objFSO.FileExists(FTPOutputFile) = True Then
objFSO.MoveFile(FTPOutputFile, FTPOutputFile1)
End If
End Sub
Thanks.
I want to keep 8 days of logs. For instance if I wanted to keep 80
days, this would be a horrible approach. How can I make this more
dynamic and efficient?
Const FTPOutputFile = "output-files.log"
Const FTPOutputFile1 = "output-files-1.log"
Const FTPOutputFile2 = "output-files-2.log"
Const FTPOutputFile3 = "output-files-3.log"
Const FTPOutputFile4 = "output-files-4.log"
Const FTPOutputFile5 = "output-files-5.log"
Const FTPOutputFile6 = "output-files-6.log"
Const FTPOutputFile7 = "output-files-7.log"
Sub Main()
'Do Stuff - gather log information
If a new day
RotateLogFiles()
End if
'Write to log....
End Sub
Sub RotateLogFiles()
'Delete Oldest Log
If objFSO.FileExists(FTPOutputFile7) = True Then
objFSO.DeleteFile(FTPOutputFile7)
End If
'Rotate logs
If objFSO.FileExists(FTPOutputFile6) = True Then
objFSO.MoveFile(FTPOutputFile6, FTPOutputFile7)
End If
If objFSO.FileExists(FTPOutputFile5) = True Then
objFSO.MoveFile(FTPOutputFile5, FTPOutputFile6)
End If
If objFSO.FileExists(FTPOutputFile4) = True Then
objFSO.MoveFile(FTPOutputFile4, FTPOutputFile5)
End If
If objFSO.FileExists(FTPOutputFile3) = True Then
objFSO.MoveFile(FTPOutputFile3, FTPOutputFile4)
End If
If objFSO.FileExists(FTPOutputFile2) = True Then
objFSO.MoveFile(FTPOutputFile2, FTPOutputFile3)
End If
If objFSO.FileExists(FTPOutputFile1) = True Then
objFSO.MoveFile(FTPOutputFile1, FTPOutputFile2)
End If
If objFSO.FileExists(FTPOutputFile) = True Then
objFSO.MoveFile(FTPOutputFile, FTPOutputFile1)
End If
End Sub
Thanks.