I am getting very interested in Microsoft Enterprise Library lately for a couple of reasons:
- It addresses a couple of common issues you will normally face, like logging, caching, and you really don't want to do those plumbing code if possible.
- It gives you a nice configuration tool ( you can open this tool within visual studio for the Enterprise Library 3) .
- It gives you all the source code, so you can see what's under the hood.
I did a brief research, and you actually have to reference another dll (Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll) in order to be able to log into the database.
Basically, you have to do the following steps :
1. The "Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll" has to be referenced.
2. The scripts under "C:EntLib3SrcApp BlocksSrcLoggingTraceListenersDatabaseScripts" has to be run against the database to create the necessary tables and objects.
3. The "Database Trace Listener" has to be added to the "Trace Listeners". For the trace listener, you have to specify the Formatter, otherwise, you will get an error.
4. Put the "Trace Listener" under the Category you want to log.
Here is a screenshot of the configuration file..