There are lots of error logging providers available such as Log4Net, AnLogger, etc. they are easy to use as well, but just to keep it simple, I have written my own. I call it “Activity and Error Logger”, it stores the data in xml format, request by request and session by session, you can actually create the user behaviour maps if you properly call the activity log at while performing any major operations. It also takes care of the concurrency, two threads will not overwrite each other. It logs the errors on page in try catch block and also at global level, in Application_Error event in global.asax

1) Include the Logging.cs class in App_Code folder of your project

2) Configure the web.config

3) Set the Application_Error in global.asax

4) Create the Logs_App and logs_Error folders in your project and you are done

5) It creates one log file on hourly basis, one for Activities and one for Errors

6) Now to log the activity or error, you just have to call the Logging.LogInfo or Logging. LogException functions in your code wherever required.

Logging.cs:

Include the Logging.cs class from the source code attached in this article

Web.config:

Add the below line in <configSections> if there is no configsections tag in your config, then create one right inside the <configuration> tag:

I have also made the admin part of the application, to create a report of activity logs, it applies the xslt on the activity log files and display them in a grid, you can extend it to create one for error log files too :