http://www.hanselman.com/blog/NuGetPackageOfTheWeek7ELMAHErrorLoggingModulesAndHandlersWithSQLServerCompact.aspx
http://docs.nuget.org/docs/start-here/Using-the-Package-Manager-Console
Steps for apply elmah for Project (WebApplication - WebSite)
1- open your solution using visual studio.
2- Open Package Manager Console
3- Install-package elmah
4-install-package elmah.sqlserver
http://docs.nuget.org/docs/start-here/Using-the-Package-Manager-Console
Steps for apply elmah for Project (WebApplication - WebSite)
1- open your solution using visual studio.
2- Open Package Manager Console
3- Install-package elmah
4-install-package elmah.sqlserver
5- go to your solution folder and find Package Folder then elmah.sqlserver.1.2 you will find sql file
Elmah.SqlServer.sql
run the script to your sql server to create elmah database.
6- after creating elmah script on your sql server Change Connection String in your web.config to be linked to your sql server instance.
7- run your project to open elmah.axd to get errors occured as http errors
8- To Apply Elmah For All Solution to log All Errors you should write this code in your functions exception handling
try
{
// your function code
}
Catch ex As Exception
Elmah.ErrorSignal.FromCurrentContext().Raise(ex)
End Try
9- to enable send Mail Using Elmah to your Mail instead of monitor errors using elmah.axd
you should change mail configuration for elmah in your web.config
<elmah>
<security allowRemoteAccess="true" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ELMAH_CONSTR" />
<errorMail from="portal@mwa.gov.sa" to="msibrahim@mwa.gov.sa" subject="خطأ في البوابة الداخلية تجريبي" async="false">
</errorMail>
<errorFilter>
<test>
<or>
<regex binding="Exception.Message" pattern="^The operation has timed out$" />
<and>
<equal binding="HttpStatusCode" value="404" type="Int32" />
<equal binding="HttpStatusCode" value="504" type="Int32" />
<regex binding="FilterSourceType.Name" pattern="mail" />
</and>
<and>
<regex binding="Exception.Message" pattern="^Logon failure: unknown user name or bad password" />
<regex binding="Exception.Message" pattern="^Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException: The Autodiscover service couldn't be located." />
<regex binding="FilterSourceType.Name" pattern="mail" />
</and>
</or>
</test>
</errorFilter>
</elmah>
10- you should edit your smtp mail server configuration in IIs Or your Web.config file
<system.net>
<mailSettings>
<smtp>
<network host="your smtp mail server" port="25" password="****" userName="******" />
</smtp>
</mailSettings>
</system.net>
11- now you will receive automatic mail when any error occurs for your web site.
thanks.
No comments:
Post a Comment