Error Logging and Management Handling in .NET is a technique by which errors are logged into database.
For doing this first you need to download DLL called Elmah.dll
Then write this code in your Web.Config file.
<?xml version="1.0"?>
<configuration>
<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>
</configSections>
<connectionStrings>
<add name="elmah-express" connectionString="Server=KAZOL-PC\SQLEXPRESS08;
Database=Elmah_Errorlog;Trusted_Connection=Yes;" />
</connectionStrings>
<elmah>
<errorLog type="Elmah.SqlErrorLog, Elmah"
connectionStringName="elmah-express" />
<errorFilter>
<test>
<equal binding="HttpStatusCode" value="404" valueType="Int32" />
</test>
</errorFilter>
</elmah>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
</httpModules>
</system.web>
</configuration>
And in the code behind throw an error for testing it
throw new Exception("test");
Then on URL type MyPage.axd
Error with log will appear
0 Comment(s)