开发者

Elmah-error logging- users- to access-email alerts

开发者 https://www.devze.com 2023-03-18 03:55 出处:网络
I have configured ELMAH to catch the errors. When I browse to the localhost:portno/elmah.axd, I can see all the errors.

I have configured ELMAH to catch the errors.

When I browse to the localhost:portno/elmah.axd, I can see all the errors.

1) I can see the errors. but I want to show this to only few roles or users. 2) How can I display errors for c开发者_运维技巧ertain duration? 3) How can I setup alert when error occurs

Where do I do this config and how?

Thank you Hari


You can secure elmah.axd with ASP.net authorization in your web.config, like so:

<location path="elmah.axd">  
    <system.web>  
        <authorization>  
            <deny users="?" />  
        </authorization>  
    </system.web>  
</location>

The duration of errors depends on which method of persistence you've configured. I would recommend using a database of some sort to store errors: SQL Server, SQLite or SQLCE, that way you can clean up errors on a scheduled basis or simply leave them forever.

To configure email alerts, you'll need to add a couple of things in your web.config. First, find your ELMAH sectionGroup and add an errorMail section, like so:

<configSections>
    <sectionGroup name="elmah">
        <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
        <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
        <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
    </sectionGroup>
</configSections>

Then add an errorMail setting to your ELMAH group:

<elmah>
    <security allowRemoteAccess="0" />
    <errorLog type="Elmah.SqlErrorLog, Elmah" />
    <errorMail from="errors@domain.com" to="errors@domain.com" subject="ELMAH error" smtpPort="25" smtpServer="localhost" />
</elmah>

You can also check out the wiki for more options or more information: http://code.google.com/p/elmah/w/list

0

精彩评论

暂无评论...
验证码 换一张
取 消