Custom Logging of Exceptions to database

Topics: Logging Application Block
Aug 25, 2009 at 10:26 AM

 Hi,

I have planned logging application block to log exceptions to database.  Now I need to customize the logging. I need only one table.(i don't need the category table). Also I need the table to have only 3-4 columns(not all the columns) and custom name for the table and the stored procedure. What modifications or code changes I have to made in the config/ code files to achieve these?

Thanks

Sarath

Aug 25, 2009 at 10:41 AM

You would need to create your own custom tracelistener which will do the logging to the database.  Refer to the documentation for the sample on how to create one. You can pattern the logic after the FormattedDatabaseTraceListener class available in the enterprise library source code.  If the values for the 3 or 4 columns you want aren't availabe in the LogEntry class, you can create your own LogEntry class and add those properties.

public class MyLogEntry : LogEntry

{

         ...additional properties here

}

Override the TraceData method of the CustomTraceListener base class so you can control which Write method you want to execute.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com