Ad Widget

Collapse

logrt - regex for log4net log rotation is processing all the files in folder

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pabloarg
    Member
    • Jun 2019
    • 32

    #1

    logrt - regex for log4net log rotation is processing all the files in folder

    Hi all,

    I have an app that uses log4net for log rotation.

    log4net generates multiple files with same name and changes extension when files are rotated.

    Click image for larger version  Name:	log4net.png Views:	0 Size:	41.8 KB ID:	422709

    I have a logrt item for reading this log and only SACMService.log file should be processed.

    I'm using this expression for item:

    logrt[\\172.29.32.194\d$\SACM\Services\SACMService\Logs\ SACMService.log,@REGEX_FOR_ERROR]

    where @REGEX_FOR_ERROR searches, for "Error" and other keywords.


    This item definition is working ok, but the problem is that ALL FILES are processed in this item, so when a log is rotated, all old alerts are open again (due file SACMService.log changes to SACMService.log.1, SACMService.log.1 changes to SACMService.log.2, and so)

    I tried fixing name in regex as:

    logrt[\\172.29.32.194\d$\SACM\Services\SACMService\Logs" SACMService.log",@REGEX_FOR_ERROR]

    (added quotes to file name), but in this case none of the files is processed.

    Please help me how I need to define file name regex in order to only get "SACMService.log" file but not the others.


    As you can see, with this regex all the files (original and other extensions) are matched by regex:

    Click image for larger version  Name:	regex.png Views:	0 Size:	35.3 KB ID:	422710

    Regards.
    Last edited by pabloarg; 12-04-2021, 19:51. Reason: typo
  • pabloarg
    Member
    • Jun 2019
    • 32

    #2
    Thanks Cyber!
    With "$" at the end seems to be working OK.

    Regards.

    Comment

    Working...