check logfile size and archivate





3
Date Submitted Thu. Mar. 2nd, 2006 11:09 AM
Revision 1 of 1
Syntax Master dannyboy
Tags LOGSIZE | VBSCRIPT
Comments 0 comments
This subroutine will rename the log file once it gets to be
larger than 10k. It renames it to ArchiveLog_(Date).txt, so
it is easy to track down a certain day.

Sub CheckLogSize()
        Dim oFSO, oFile, sLogFile, sOldLogFile
        sLogFile = "d:\log.txt"

        Set oFSO = CreateObject("Scripting.FileSystemObject")
        Set oFile = oFSO.GetFile(sLogFile)

        If oFile.Size > 10000 Then
                Dim sTemp, oRE, sDate

                sTemp = Date
                Set oRE = New RegExp
                oRE.Global = True
                oRE.Pattern = "/"
                sDate = oRE.Replace(sTemp, "_")

                oFile.Name = "ArchiveLog_" & sDate & ".txt"
                Set oRE = Nothing
        End If

        Set oFile = Nothing
        Set oFSO = Nothing
End Sub
 

Comments

There are currently no comments for this snippet.

Voting