Think you could make 2 target-pipelines. First pipeline that fires instantly on first error, and a second pipeline that fires every 6 minutes.
<targets>
<target type="Mail" name="email" />
<target type="LimitingWrapper" name="emailInstant" messageLimit="1">
<target-ref name="email" />
</target>
<target type="BufferingWrapper" name="emailLazy" flushTimeout="360">
<target-ref name="email" />
</target>
</target>
<rules>
<logger name="*" minLevel="Warn" writeTo="emailInstant, emailLazy" />
</rules>
See also: https://github.com/NLog/NLog/wiki/LimitingWrapper-target
See also: https://github.com/nlog/NLog/wiki/BufferingWrapper-target
I guess one could extend the NLog LimitingWrapper with a new option messageBatchLimit
(PullRequests are welcome). That instead of limiting the individual number of messages, then one could do like this to limit the number of message-batches:
<targets>
<target type="BufferingWrapper" name="emailbuffer" flushTimeout="5">
<target type="LimitingWrapper" name="emailBuffer" messageBatchLimit="10">
<target type="Mail" name="email" />
</target>
</target>
<targets>
<rules>
<logger name="*" minLevel="Warn" writeTo="emailBuffer" />
</rules>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…