我想在我的應用程序中設置錯誤記錄的ELMAH。這裏是我的web.config:ELMAH不從本地主機發送電子郵件
數據庫<configuration>
<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" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
</configSections>
<elmah>
<security allowRemoteAccess="0" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="AppDb" />
<errorMail from="[email protected]" to="[email protected]" subject="Elmah Error" smtpServer="localhost" />
</elmah>
<connectionStrings>
<add name="AppDb" connectionString="Server=***;Database=***;Trusted_Connection=yes;" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
</httpModules>
<customErrors mode="Off" defaultRedirect="Error.aspx">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
</modules>
<handlers>
<add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</handlers>
</system.webServer>
</configuration>
我的應用程序記錄錯誤,但電子郵件沒有得到發送出去。
我不知道是否因爲我在本地機器上,如果我的web.config錯誤,或者如果它完全是其他東西。
另一種選擇是使用一個替代的SMTP服務器,比如一個互聯網服務供應商報價。或者,您可以使用Gmail發送錯誤電子郵件,如下所述:http://scottonwriting.net/sowblog/archive/2009/05/21/163350.aspx – 2011-02-13 04:03:00