Skip to content

BurstFilter is not working when using lossy buffering #1

@KnackiX4

Description

@KnackiX4

Hi,

First, I love BurstFilter :)

But taking the example of these settings, with bufferSize and lossy settings changed, and using an evaluator instead of a simple threshold :

<appender name="SMTPAppender" type="log4net.Appender.SmtpAppender,log4net">
  <bufferSize value="3"/>
  <authentication value="Basic" />
  <to value="to@example.com" />
  <from value="from@example.com" />
  <subject value="Automatmail: system X is totally broken, please fix" />
  <smtpHost value="smtp.example.com" />
  <username value="username"/>
  <password value="password"/>
  <lossy value="true" />
  <evaluator type="log4net.Core.LevelEvaluator">
    <threshold value="WARN" />
  </evaluator>
  <filter type="Kentor.Log4NetExtensions.BurstFilter,Kentor.Log4NetExtensions.BurstFilter">
    <!-- Allow two mails a minute on average, with bursts up to 20 mails -->
    <BurstLength value="00:10:00"/>
    <BurstSize value="20"/>
  </filter>
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%property{log4net:HostName}%newline%date user:%aspnet-request{AUTH_USER} %-5level %logger %newline %message%newline%exception%newline%newline"/>
  </layout>
</appender>
<root>
  <level value="ALL" />
  <appender-ref ref="SMTPAppender" />
</root>

BurstFilter is seeing all events passing (even INFO or DEBUG events), and counting them, then when the evaluator is seeing a WARN event passing through, it is too late. No mail is sent, because the counter has reached the limit, and the WARN event is denyed.

The ideal fix for this would be to have Burstfilter able to read the evaluator settings (when lossy is set to True), get the Threshold value, and act accordingly.

In the meantime, I propose this workaround where you can set a Threshold directly in BurstFilter settings (which should be with the same value as in the evaluator settings for buffering).

  <filter type="Kentor.Log4NetExtensions.BurstFilter,Kentor.Log4NetExtensions.BurstFilter">
    <BurstLength value="00:10:00"/>
    <BurstSize value="20"/>
    <Threshold value="WARN" />
  </filter>

See attached file.

Regards

BurstFilter.cs.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions