Announcement

Collapse
No announcement yet.

Looking for a Log File Interval Script.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Looking for a Log File Interval Script.

    I'm really new @ this. So please be patient with me.
    I'm trying to get my log file to write on a "Per Day Basis" is there anyway I can get a script that will write the log's for that day, and write them into a file that has the date in the filename ? If anyone could help me it would help me tremoundiously.
    Charles

    #2
    Here's a little script that will write yesterdays log file entires to a file named like 10302002.txt. If you want all of yesterdays log entries it will need to be run after midnight. So set up an event that has a trigger type of "Absolute time/Date" with a time shortly after midnight with every day elected. This will then write a file with the prior days entries in it. This does not do anything to the original ah.log file contents.

    <pre class="ip-ubbcode-code-pre">
    Sub main()
    Dim MyDate
    Dim LineDate
    Dim fso

    ' May need to change this if HS is not installed in the default directory.
    LogFile = "c:\program files\HomeSeer\ah.log"

    DailyFileName = Replace(Date - 1, "/", "")

    ' Change this to the path where you want to store the new daily log files
    NewFile = "c:\temp\" & DailyFileName & ".log"

    Set fso = CreateObject("Scripting.FileSystemObject")

    Set file1 = fso.OpenTextFile(NewFile, ForWriting, True) ' or substitute 2 for the word ForWriting
    Set file = fso.OpenTextFile(LogFile, 1)

    Do Until file.AtEndOfStream
    'Read a line from the log file.
    Myline = file.ReadLine

    ' Set MyDate equal to yesterday.
    MyDate = CStr(Date - 1)

    ' Find the date (up to first space)
    position1 = InStr(1, Myline, " ")
    If position1 Then
    LineDate = Mid(Myline, 1, position1 - 1)

    ' If the data matches yesterday then write it to the new file
    If MyDate = LineDate Then
    file1.Write (Myline) & vbCrLf
    End If



    End If
    Loop
    file1.Close
    End Sub
    </pre>

    Let me know how it goes.

    -Rupp
    ...One Nation Under GOD, Indivisible, With Liberty And Justice For All.
    -Rupp
    sigpic

    Comment


      #3
      Script error in file: 5:Invalid procedure call or argument in line 16.

      Here is Line 16 :
      Set file1 = fso.OpenTextFile(NewFile, forWriting, True) ' or substitute 2 for the word ForWriting


      Any thing you can do to help, I greatly appreciate it, Oh and Thanks for helping me out with this.
      Charles

      Comment


        #4
        Its right in the line
        Set file1 = fso.OpenTextFile(NewFile, forWriting, True) ' or substitute 2 for the word ForWriting

        take ut the word forWriting and put a 2 in its place. Like this:
        Set file1 = fso.OpenTextFile(NewFile, 2, True)

        -Rupp
        ...One Nation Under GOD, Indivisible, With Liberty And Justice For All.
        -Rupp
        sigpic

        Comment


          #5
          Thank for your help I really appreciate it !

          Comment

          Working...
          X