功能:給網站記錄錯誤日誌
添加:在NuGet中搜索ELMAH並添加Elmah.MVC
使用:
<elmah>
<security allowRemoteAccess="0" />
<errorMail from="發件箱地址"
to="收件箱地址"
subject="網站錯誤日誌"
priority="High"
async="false"
smtpPort="25"
smtpServer="smtp.163.com"
useSsl="true"
noYsod="false"
userName="郵箱賬號"
password="郵箱密碼" />
<errorFilter>
<test>
<and>
<!--過濾400到499的錯誤 部分url轉發可能會引發404錯誤 -->
<greater binding="HttpStatusCode" value="399" type="Int32" />
<lesser binding="HttpStatusCode" value="500" type="Int32" />
<!--<equal binding="HttpStatusCode" value="404" type="Int32" />-->
<!--過濾404錯誤-->
</and>
</test>
</errorFilter>
</elmah>
效果: