Today i came to know about the great open source .net project named as ELMAH when i was searching about the error logging techniques.
There are many tutorials available on internet but i can give you the simple steps and some useful link, so you can quickly do that without searching so much stuff.
Please visit the official link from here who has developed this.
Followings are simple steps to implement error logging in your existing asp.net web application.
- Download Elmah.dll and add reference of it.
- Set below parameters in web.config.
<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>
<elmah>
<!--this is neccessory when you'll put it on live-->
<security allowRemoteAccess="yes" />
<!--to save it on error log in database-->
<errorLog type="Elmah.SqlErrorLog, Elmah"
connectionStringName="some_con_string" />
</elmah>
<HttpHandler >
<add verb="POST,GET,HEAD" path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah" />
<HttpModule>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
That's it , now if you do not want to add error log in database then comment <elmah> section and run your application and on root write URL like this http://localhost:52584/elmah.axd.
If you want to add error log in database then just uncomment <elmah> section and download source from here .
Extract that and in that under \src\Elmah directory you will find database script for Sql Server , MySQL and Oracle , you can run script as per your database choice.
In my case i have used sql server and modified <elmah> section as per below
<elmah>
<security allowRemoteAccess="yes" />
<errorLog type="Elmah.SqlErrorLog, Elmah"
connectionStringName="Connectionstr" />
</elmah>
You can find detailed description from Asp.Net/C# forum tutorial
cheers..
No comments:
Post a Comment