Prevent Elmah to send mail on specific type of errors but log them to db.

Approach 1 :

The below filter when added, will stop both — sending out error email and logging to the db.

<errorFilter>
<test>
<!--<equal binding="HttpStatusCode" value="404" type="Int32" />-->
<regex binding="BaseException.Message" pattern="404 request received" />
</test>
</errorFilter>

Approach 2 :

The below filter will only stop sending out mail, but will continue to log to the db.

<errorFilter>
<test>
<or>
<and>
<regex binding="BaseException.Message" pattern="404 request received" />
<regex binding="FilterSourceType.Name" pattern="mail" />
</and>
<and>
<regex binding="BaseException.Message" pattern="Any xyz pattern can go in here..." />
<regex binding="FilterSourceType.Name" pattern="mail" />
</and>
</or>
</test>
</errorFilter>
Like what you read? Give Yasser Shaikh a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.