step1. 安裝elmah 套件網址如下
https://code.google.com/p/elmah/
step2.ASP.NET 專案中選擇安裝 ELMAH on XML Log 這個 NuGet 套件
http://www.nuget.org/packages/elmah.xml
PM> Install-Package elmah.xml
step3.預設會將所有收集到的錯誤儲存成 XML 格式並置於專案的 ~\App_Data\Elmah.Errors 目錄下。
打開web.config
找到 <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/Elmah.Errors" /> 註解掉
step4.
將以下這段
<!--<modules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
</modules>-->
改為以下這段
<modules runAllManagedModulesForAllRequests="true">
<remove name="ErrorLog" />
<remove name="ErrorMail" />
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
</modules>
step5. 請設定
<add name="elmah-sqlserver" connectionString= "連線字串請設定"
step6. 設定好後 127.0.0.1/elmah 就可以看到 log了!!
step7.設定將log丟到mail
<elmah>
<!--
See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for
more information on remote access and securing ELMAH.
-->
<security allowRemoteAccess="false" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="elmah-sqlserver" /><!--elmah-sqlserver-->
<!--<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/Elmah.Errors" />-->
<errorMail from="test@gmail.com" to="test@gmail.com" subject="enjoyapi 錯誤log :" async="false" smtpPort="0" useSsl="true" />
</elmah>
<!--System.net Mail setup-->
<system.net>
<mailSettings>
<smtp deliveryMethod="network">
<network host="smtp.gmail.com" port="587" userName="test@gmail.com" password="test" />
</smtp>
</mailSettings>
</system.net>
https://code.google.com/p/elmah/
step2.ASP.NET 專案中選擇安裝 ELMAH on XML Log 這個 NuGet 套件
http://www.nuget.org/packages/elmah.xml
PM> Install-Package elmah.xml
step3.預設會將所有收集到的錯誤儲存成 XML 格式並置於專案的 ~\App_Data\Elmah.Errors 目錄下。
打開web.config
找到 <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/Elmah.Errors" /> 註解掉
step4.
將以下這段
<!--<modules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
</modules>-->
改為以下這段
<modules runAllManagedModulesForAllRequests="true">
<remove name="ErrorLog" />
<remove name="ErrorMail" />
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
</modules>
step5. 請設定
<add name="elmah-sqlserver" connectionString= "連線字串請設定"
step6. 設定好後 127.0.0.1/elmah 就可以看到 log了!!
step7.設定將log丟到mail
<elmah>
<!--
See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for
more information on remote access and securing ELMAH.
-->
<security allowRemoteAccess="false" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="elmah-sqlserver" /><!--elmah-sqlserver-->
<!--<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/Elmah.Errors" />-->
<errorMail from="test@gmail.com" to="test@gmail.com" subject="enjoyapi 錯誤log :" async="false" smtpPort="0" useSsl="true" />
</elmah>
<!--System.net Mail setup-->
<system.net>
<mailSettings>
<smtp deliveryMethod="network">
<network host="smtp.gmail.com" port="587" userName="test@gmail.com" password="test" />
</smtp>
</mailSettings>
</system.net>