How do I configure a log4net SmtpAppender to only send me e-mails when a certain level is hit?

妖精的绣舞 提交于 2019-12-05 10:40:40

You need to set the lossy value to true:

<lossy value="true" />

In your configuration log4net writes the buffer not only when an error is logged but also when the buffer is full. The lossy flag tells log4net to discard messages if necessary.

Use

<threshold value="WARN"/>

The

<evaluator type="log4net.Core.LevelEvaluator">
   <threshold value="WARN"/>
</evaluator>

seems not to work (log4net version 1.2.13.0) anymore...

Using

<lossy value="true" />

is not good when one does want to get the messages.

chrismead

I'd give this a try:

How do I Filter on a custom Level in log4net?

Filtering works nicely for me in other 'scenarios'.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!