This project is read-only.

Adding CouchDB Trace Listener for MS Enterprise Library

Dec 14, 2010 at 11:38 PM

Would it be a good idea to add a CouchDB Trace Listeners for Microsoft Enterprise Library 5.0 as part of the project?

Dec 16, 2010 at 9:12 AM

I had not thought of that; honestly I'm not very fond of the Enterprise Library, but it might be worth to take a look. Could you describe a simple scenario? 

Dec 17, 2010 at 12:31 AM

MS Enterprise Library do have these Trace Listeners used for logging today:

  • The event log
  • An e-mail message
  • A database
  • A message queue
  • A text file
  • System Diagnostics TraceListener
  • A Windows® Management Instrumentation (WMI) event

So the scenario would be to be able to log to CouchDB. 

I'm using windows event log and MS SQL Server database for logging today. Since I have now started to use CouchDB in one project, I thought it would be a good idea to start using CouchDB also for holding logging data and statistics. After searching the Internet I found this project and thought it would be a good addition to add a CouchDB Trace Listener.

Far as I know all that is needed to be done is to implement a specific interface. A json formatter may also be needed.



Dec 17, 2010 at 6:31 AM

OK, that's different that what I had in mind which were CouchDBs own traces that are not implemented.

You may do that yourself in your own project, you have everything you need for that.

You just need to reference the CouchDB.NET project in your solution and the related dlls, included in the CouchDB.NET project, on the Lib folder (EasyHTTP, JsonFX and StructureMap).

One easy way to do it would be to create a class to hold all your trace data. Make that class inherit CouchDbBase. Then create a CustomTraceListener and on the TraceData method simply create and instance of your trace data class, fill it with the required information and then create an instance of CouchDbRepository passing it your CouchDb Server configuration and call SaveWithId on the repository passing your trace data object instance. This will save the object in the database.

To read the data back you'll need to create the CouchDb views that you wish and use again a CouchDbRepository to make the calls.

The CouchDbRepository is also meant to be inherited to make this operations easier. Take a look at the CouchDbRolesRepository class in the CouchDb.ASP.NET project to see a sample on how to do that.

Please let me know if this helps.