Logging Application block with custom tables and data base

Topics: Exception Handling Application Block, Logging Application Block
Nov 11, 2008 at 4:31 PM

        I am  very beginner using EL. I understand creating the  database listener and inserting data into logging database which is supplies by microsoft. Below is my requirement.

               Point 1. i want to log some important actions into Action Table.
                    Ex: i want to add record in Action Table, When user add new  Application(its notmal web form which create new record in database).
               Point  2. I want to write error info in Error Table.
                    Ex:  I  want to log the error in data base (user name, date time, Initiated page, Initiated method, Class/form Name(the actal place where error is initiating), Method Name(the actal method where error is initiating), line number and Error Message.
                Point 3. I want to write error message in event log when error occurs in  point 1 or 2.

Can you please advice me how i can handle the above requirement?

Thanks in advance
Ravi Potturi
Nov 12, 2008 at 5:37 AM
Edited Nov 12, 2008 at 9:18 AM

For your point 1: You can try implementing a custom trace listener similar to the fuctionality of the DatabaseTraceListener but only with your custom table and sproc.

try this link, it help you how to create a custom trace listener:  http://msdn.microsoft.com/en-us/library/cc511727.aspx

For your point 2: This is also addressed by your point # 1. But remember when you construct your logentry, you can add your extra parameters to the ExtendedProperties of the logEntry and extract is later when you need to.

just like on this post: http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=36737

For your point 3: You can handle exceptions that occurs in the above 2 items and log them to event log.

try this link : http://msdn.microsoft.com/en-us/library/cc511568.aspx 

---> Related posts

---> Sample Project with CustomDatabaseTraceListener

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
Nov 14, 2008 at 12:56 AM
Hi Valiant,

                Thanks for your help. It helps a lot. Now I am able to configure the block and working fine.

Ravi Potturi
Nov 25, 2010 at 6:34 AM

Hi Ravi,

Can you please share your code. I want to implement same scanrio which you did. Looking forward to your reply.