Log File with Dynamic name

Hi All,

We need to monitor a xml file - E:\logs\abcLogs\2016-12-16\ctsweb.xml although monitor is reading logfile with the path E$\logs\abcLogs\2016-12-16\ctsweb.xml but to handle dynamically for daily logs, I created s/E\$\\logs\\abcLogs\\$year$-$0month$-$0day$\\ctsweb.xml/ but it is showing unable to read.

Appreciate if some expert can help here.

Regards,

Navaid

Parents
  • Verified Answer

    Hi Navaid,

    I tested for quite some time and found that this worked on my box
    (SiteScope 11.33 on Windows, should be the same on 11.32):

    I created directories
    C:\logs\abclogs\2016-12-19\
    and the file
    ctsweb.xml
    underneath,
    so the full name is
    C:\logs\abclogs\2016-12-19\ctsweb.xml

    The regular expression below finally worked (without quotes!)
    "s/C:\logs\abclogs\$year$-$0month$-$0day$\ctsweb.xml/"

    Debug logging shows that the date variables are substituted as expected:

    DEBUG - Log name [s/C:\logs\abclogs\$year$-$0month$-$0day$\ctsweb.xml/] was substituted with: C:\logs\abclogs\2016-12-19\ctsweb.xml

    and the monitor reads from that very file:

    DEBUG - Start reading file s/C:\logs\abclogs\$year$-$0month$-$0day$\ctsweb.xml/ from beginning
    INFO - * checkLog(C:\logs\abclogs\2016-12-19\ctsweb.xml): isMultiLineSearch=false

     

    One would think that this regular expression doesn't work at all, and in fact SiteScope's Tool returns an error, same for external regular expression testing tools like https://regex101.com/ would fail, but here it works fine.
    I guess you might need to experiment with the "E$" a little bit,
    mist likely "s/E$\logs\abcLogs\$year$-$0month$-$0day$\ctsweb.xml/" will work.
    Individual Debug Logging (Monitor Properties -> Logging Settings) is your best fried for testing.

    Greetings
    Siggi

Reply
  • Verified Answer

    Hi Navaid,

    I tested for quite some time and found that this worked on my box
    (SiteScope 11.33 on Windows, should be the same on 11.32):

    I created directories
    C:\logs\abclogs\2016-12-19\
    and the file
    ctsweb.xml
    underneath,
    so the full name is
    C:\logs\abclogs\2016-12-19\ctsweb.xml

    The regular expression below finally worked (without quotes!)
    "s/C:\logs\abclogs\$year$-$0month$-$0day$\ctsweb.xml/"

    Debug logging shows that the date variables are substituted as expected:

    DEBUG - Log name [s/C:\logs\abclogs\$year$-$0month$-$0day$\ctsweb.xml/] was substituted with: C:\logs\abclogs\2016-12-19\ctsweb.xml

    and the monitor reads from that very file:

    DEBUG - Start reading file s/C:\logs\abclogs\$year$-$0month$-$0day$\ctsweb.xml/ from beginning
    INFO - * checkLog(C:\logs\abclogs\2016-12-19\ctsweb.xml): isMultiLineSearch=false

     

    One would think that this regular expression doesn't work at all, and in fact SiteScope's Tool returns an error, same for external regular expression testing tools like https://regex101.com/ would fail, but here it works fine.
    I guess you might need to experiment with the "E$" a little bit,
    mist likely "s/E$\logs\abcLogs\$year$-$0month$-$0day$\ctsweb.xml/" will work.
    Individual Debug Logging (Monitor Properties -> Logging Settings) is your best fried for testing.

    Greetings
    Siggi

Children