Recommendation: Tippu I highly recommend you use ELMAH instead. It is as easy as possible to set up and will make your life so much easier (You will never write your own logging program again). It even catches unhandled exceptions!
Check out the following website on what it is and how easy it is to set up
ELMAH
Security: The only thing you MUST be aware of is that you must secure ELMAH otherwise your session can be hijacked. However, it is very easy to secure it. Have a look at the following website on the security issue and how to secure it.
ASP.NET Session Hijacking
5-10 Minute Setup Steps
Go to Nuget, search for "ELMAH SQL" and install "ELMAH on MS SQL Server".
In your "App_Readme" folder there will be a "Elmah.SQLServer.sql" file which installs a table and 3 stored procedures. Run it in the database you want this connected too. (You will have to set permissions for the Stored procedure in a live server so that it can read and write to it)
Go to your web config (You will notice that ELMAH has automatically updated it for you). Find , if you don't want to have remote access leave it as is and I believe it will be secured.
If you want to allow remote access so that you can view the Error Log website anywhere you need to set it to true. You then MUST secure it. The below will secure it for Admin and deny all other users. Check out this website for more information Secure ELMAH
<location path="elmah.axd">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD"
path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<authorization>
<allow roles="admin" />
<deny users="*" />
</authorization>
</system.web>
<system.webServer>
<handlers>
<add name="ELMAH"
verb="POST,GET,HEAD"
path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah"
preCondition="integratedMode" />
</handlers>
</system.webServer>
Go to your connection strings and point the "elmah-sqlserver" connection string to your specific Database.
Go to your try catches and in the catch section add "ErrorSignal.FromCurrentContext().Raise(ex);"
Your application will now catch Handled and Unhandled Exceptions and write the errors to a SQL Server Table. To view the errors open up a browser and go to "yourwebsite/elmah.axd"
You can also set it up so the errors are sent to you. Check out the following website on how to do that: Setup ELMAH Email
Ignore the above number ordering