« Previous Next »

Thread: Specifying log file based on date

Last post 12-29-2005 10:10 AM by LogParser User : DEinspanjer. 1 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (2 items)

Sort Posts:

  • 12-28-2005, 1:34 PM

    Specifying log file based on date

    Hi, I wrote a simple vb.net script to parse my daily IIS log file and output to a SQL server. My task right now is for the parser app to run after midnight each night and parse the log file for the previous day. I'm a novice programmer so I'm sure the syntax is simple but any help in the right direction would be appreciated.

    Thanks
  • 12-29-2005, 10:10 AM In reply to

    RE: Specifying log file based on date

    Here you go..


    option explicit

    dim dateMod

    If WScript.Arguments.Count <> 1 Then
    dateMod = -1
    Else
    dateMod = WScript.Arguments(0)
    End If

    dim y
    y = DateAdd("d", dateMod, Date)

    dim yS(2)
    yS(0) = Year(y)
    yS(1) = Month(y)
    yS(2) = Day(y)

    dim i
    for i = 1 to 2
    if 1 = Len(yS(i)) then yS(i) = "0" & yS(i)
    next
    WScript.Echo Join(yS, "")


    This can be invoked from the command line with the following in a batch script:

    @ECHO OFF
    FOR /F %%s in ('cscript //NoLogo GetRelativeDate.vbs') DO (
    SET LOG_DATE=%%s
    )
    ECHO %LOG_DATE%
Page 1 of 1 (2 items)
Microsoft Communities