Thêm nhật ký email vào Web.Release.config của bạn. Web.config cơ sở của tôi không chứa bất kỳ công cụ nào của Elmah - tất cả đều được thêm vào khi biên dịch với bản phát hành. Nếu bạn biên dịch để phát hành và chạy cục bộ, nó sẽ gửi email và đăng nhập, nhưng một bản sửa lỗi thường xuyên sẽ không.
Web.Release.config
<configSections>
<sectionGroup name="elmah" xdt:Transform="Insert">
<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>
<connectionStrings>
<clear/>
<add xdt:Transform="Insert" name="ErrorLogs" connectionString="...." />
</connectionStrings>
<elmah xdt:Transform="Insert">
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ErrorLogs" />
<security allowRemoteAccess="0" />
<errorMail ...Email options ... />
</elmah>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<httpModules xdt:Transform="Insert">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
</httpModules>
</system.web>
<system.webServer>
<modules xdt:Transform="Insert" runAllManagedModulesForAllRequests="true">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
</modules>
</system.webServer>
</configuration>
Cuối cùng, cần lưu ý rằng Web.config cơ sở của bạn nên có thẻ <configSections>
lúc bắt đầu, ngay cả khi nó rỗng:
Web. config
<configuration>
<configSections /><!-- Placeholder for the release to insert into -->
....