I was recently introduced to log4net by Ed Kisinger of EdSquared.com and absolutely love the project.  I've previously used to Logging Application Block inside Enterprise Manager for my logging, and would again if I was using the rest of EntLib, but log4net fills the wonderful point where you may not want to take on all of EntLib and still have excellent logging.

log4net abstracts the actually logging on messages from the location that a log will be stored.  As such it is easy to change from file logging, to UDP network logging to Database logging, all without touching the code which actually logs.  Fantastic idea!  The Appender model, as they call this, includes many excellent Appenders right out of the box.

In particular, I wanted to use to AdoNetAppender to log my messages to a database.  Easy enough, the simple example included in the AdoNetAppender documentation logs the most basic of information.  But as you dig deeper into what information log4net can store, you begin to realize how oversimplified this structure really is.

It would be a reasonable thing to say that I can sometimes be a bit of a perfectionist.  As such I spent this morning creating a database structure capable of holding all of the log4net information, properly normalized to the third normal form.  If you would like to be able to store any information available from log4net when logging to a database, then feel free to take this structure and adapt it to your needs.

The only personalized piece of this database at the moment is the inclusion of a column for storing a property called InstanceId.  As I work with BizTalk on a regular basis, and love Scott Colestock's BizTalk Deployment Framework, I included a column for the Orchestration instance id which his Serializable log4net extension includes.

Download Version 1.0 of log4net Database