If you need Logging in your application and Log4Net is not an option (for whatever reason), then the "Logging Application Block" that is part of the Microsoft Enterprise Library may be a good choice.
I will look at Enterprise Library Version 4.1 - October 2008, which is available for download here, because is supports Windows Server 2003.
If you are not already familiar with the concepts of logging, i recomend to read this rather technical blog-entry "Log Event to Listener Routing in Enterprise Library".
So, what do we need if we want to log from a SharePoint-Solution into a database or text-file ?
Well, first of all download and install the Enterprise Library 4.1.
Then, we need to reference some assemblies:
- Microsoft.Practices.EnterpriseLibrary.Common.dll
- Microsoft.Practices.EnterpriseLibrary.Logging.dll
- Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.Design.dll
- Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll
- Microsoft.Practices.ObjectBuilder2.dll
Now there are two things missing before we can enjoy the Logging:
- the logging-database
well, we could log to a textfile. But with SharePoint we already use one (or more) databases, so we'd like a database for the log, too.
- the configuration
that's part of the web.config
Finally, the link to the MSDN documentation on the Logging Application Block.