tags:

views:

129

answers:

1

Hi,

I have ELMAH set up for a webapp, logging exceptions to a SQL server.

I wish to have ELMAH send me an email too, but only when a specific exception is thrown (ie. MySpecialException).

ELMAH must still log all exceptions to SQL server.

I know you can do it programmatically in global.asax, but I'd prefer to use web.config.

So, how do I restrict ELMAH error mails to filter out everything but a specific exception type, using web.config?

UPDATE

The filter ended up looking like this:

<test>
    <and>
        <not>
            <is-type binding="Exception" type="MyApp.MySpecialException" />
        </not>
        <regex binding="FilterSourceType.Name" pattern="mail" caseSensitive="false"/>
    </and>
</test>
A: 

Its certainly possible to do. Check out the filtering documentation for elmah.

In particular look at the section Filtering By Source

<elmah>
...
<errorFilter>
    <test>
        <and>
            <equal binding="HttpStatusCode" value="404" type="Int32" />
            <regex binding="FilterSourceType.Name" pattern="mail" />
        </and>
    </test>
</errorFilter>

Joel Cunningham
Have looked at the documentation. Afraid I need more help than that.I'm stuck at this: <and> <not binding="Exception" pattern="StackOverflow" /> <not binding="FilterSourceType.Name" pattern="mail" /></and>.. which does not work.
Sir Code-A-Lot
This could be for a number of reasons. Have you added ErrorFilterModule to the HttpModules? Might be an idea to add all of your elmah configuration to your post.
Joel Cunningham
This question may also help.http://stackoverflow.com/questions/1788900/filter-on-exception-text-in-elmah
Joel Cunningham
Thanks, it did...
Sir Code-A-Lot