Logging

Given the scope of the reporting platform, one of the first things we identified we needed is a framework to provide common functionality. These help you standardize components, structure data while solving the problem of migration or upgrade at one place and one time

One of them first pre-requisites for customer facing component has got be Logging or Tracing as you would like to call it. Logging is highly useful to troubleshoot or debug issues, capturing errors, auditing code paths or events as they occur. The analysis of these logs can lead to increased code quality, improved business scenarios, quick turnaround on issues as they arise and high predictability in getting to the root cause of an issue among other things.

A few choices for the logging component we could use were:

  • Write our own customizable listeners, writers, formatters as part of our logging library
  • Write custom TraceProvider utilizing the underlying MOSS framework to emit logs into ULS
  • Enterprise Library

In the end our choice was to use Enterprise library as our core component for logging functionality since it encompasses and provides beyond what 1 and 2 above offers. In order to maintain consistency and to standardize the logging functionality while ensuring backward compatibility, we provided a wrapper class around the Enterprise Library's Logger functionality. To the consuming component or application we abstract all the base functionality and provide four simple methods Debug, Info, Warn, and Error.

Config File: Once the consuming application or component integrates the library for logging, they use a configuration file to drive Logger to emit the tracing statements to a common destination. This common destination could be windows trace, flat file, event viewer, database or a remote service. This file needs to be part of the main application's config file (app.config/web.config/[MAIN APPLICATION NAME].exe.config).

We provided a SharePoint solution using SPWebConfigModification which allowed us to add Enterprise Library related config entries to any web application in our farm. The same solution was added to the central admin, SSP Admin as well as our main site.

For viewing the logs as they are being written, tenants would use tail/sql query/DebugView/trace listeners/event viewer/e-mail inbox/custom destination depending on how the destination(s) is configured.