Have You ever been in a project where the development is almost complete and we have released our application to QA and the QA team is complaining they can't even login and you are trying to figure out what the problem is and we will be thinking, it would have been easier if we would have implemented the logging, so it is easy to debug the issue in server. ELMAH can be the face saver. You can implement logging without touching the code base and everything is configurable and it works seamlessly.
1. Go to Package manager console in Visual Studio
2. Select
Default Project as project where you want to install Elmah
3. Run
the below command in the PM
Install-Package Elmah.Contrib.WebApi
Install-Package Elmah.Contrib.WebApi
4. Copy
the below code in Web.Config/App.Config
Code:
5. Copy
the below code in <system.web> of WebConfig
(if not exist add in the <configuration> section)
Code:
6. Add below code to <system.webServer> of WebConfig (if not exist add in the <configuration> section)
Code:
7. Comment
below code if available
<!--<modules
runAllManagedModulesForAllRequests="true" />-->
8. Add
the below code to <handlers>
of <system.webServer>
Code:
9. Add
below code to
<configuration>.
Please change the logPath based on where you want your log file to exist. You
can also write your log in network path and also send an email to specified
email address.
Code:
10. You
should see your log in elmah log in your elmah_log(based on your logpath
configuration)