Project Description
Custom trace listener in .Net which writes trace entries to database table as XML data. You use it just like any other .Net Trace Listener using app.config file

.Net Framework provides built-in trace listeners for you to write trace information to various destinations such as text file, event viewer, web page, console, and XML file. But we don't have a listener which can write trace information to a database table. This project creates a new trace listener which can write trace information to a database table. You use this new trace listener in same way as you'd use any other trace listener provided by .Net Framework. Simplest way is to add a trace listener using application configuration file and provide additional details such as database connection string and you would be good to start. Of course, you need to run a very small SQL script on your database, which will create a single table and a stored procedure, used for storing trace information.

There are lot of benefits of storing tracing information in database table. Think of managing information
in a file or event viewer. Searching for information in file or event viewer is like looking for a needle in the haystack. You run into maintenance issues very soon and it becomes a headache. But with database table storing all your trace information, retrieval as well as maintenance becomes an easy task as compared to other trace destinations. You could run a scheduled job which can delete entries beyond certain age, as an example. You could leverage all the power of SQL queries to filter, group, order the output, etc.

All said and done, using a database table as your trace information destination may not be suited for every application, especially the ones which have high network latency involved for establishing connection to database server, or applications which have very high trace output generated in a small time window. So, assess your situation before making a decision. But there is no rush to decide. You don't need to decide during development but can take a call after the application is in production environment too, simply because you can always turn tracing off or filter the information getting dumped using trace switch, if you find it does not suit your application.