This project has moved and is read-only. For the latest updates, please go here.

See also

Using CuttingEdge.Logging with the Common.Logging façade

The Common.Logging façade is an abstraction over logging frameworks. It allows you to select a specific logging implementation at runtime. Thus you can defer the decision what particular logging library to use until deployment. The download of the current CuttingEdge.Logging release contains an adapter for the Common.Logging interface and therefore allows users to abstract the use of CuttingEdge.Logging away. This allows users to use the simple configuration model of CuttingEdge.Logging, while being able to replace CuttingEdge.Logging easily with another logging framework when needed.

The Common.Logging adapter for CuttingEdge.Logging also adds the notion of hierarchical loggers to CuttingEdge.Logging. This is a feature CuttingEdge.Logging doesn't support natively, because it is thought to be an advanced feature. Naming logging providers as namespaces (such as 'Company.Product.Layer'), will allow the adapter to resolve loggers in an hierarchical manner. This works, because users will typically create a Common.Logging logger based on the name of a type.

Below is an example of a configuration that hides CuttingEdge.Logging behind the Common.Logging façade and while allowing loggers to be accessed in an hierarchical manner.

<?xml version="1.0"?>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
<sectionGroup name="cuttingEdge">
<section name="logging"
type="CuttingEdge.Logging.LoggingSection, CuttingEdge.Logging" />

type="Common.Logging.CuttingEdge.CuttingEdgeLoggerFactoryAdapter, Common.Logging.CuttingEdge" /

<logging defaultProvider="root">
<add name="root" type="CuttingEdge.Logging.TerminatorLoggingProvider" />
<add name="Company" type="CuttingEdge.Logging.XmlFileLoggingProvider"
path="company.log" />
<add name="Company.Product" type="CuttingEdge.Logging.WindowsEventLogLoggingProvider"
logName="[MyApplication]" source="Product"
<add name="Company.Product.Layer1" type="CuttingEdge.Logging.CompositeLoggingProvider"
provider2="Company" />
<add name="Company.Product.Layer2" type="CuttingEdge.Logging.WindowsEventLogLoggingProvider"
logName="[MyApplication]" source="Layer2"
<add name="FileLogger" type="CuttingEdge.Logging.XmlFileLoggingProvider"
="log.xml" threshold="Error"


Note that for this example to work you need to reference the Common.Logging.dll, CuttingEdge.Logging.dll, and Common.Logging.CuttingEdge.dll assemblies in the startup project of your solution (please note that the Common.Logging.dll is not included in the downloads. You can download it from the Common.Logging website).

While this is a rather complex example of a configuration, it does show what you can do with CuttingEdge.Logging when you integrate it with the Common.Logging façade:

  • The example shows how the TerminatorLoggingProvider is configured as default provider, which means that Common.Logging will see it as the ‘root’ logger (the name of the logger is not of any importance for this). When the Common.Logging adapter could not find a suited provider by examining the type name, the default provider will be used. The TerminatorLoggingProvider will ignore all logging events.
  • The example shows that loggers are named by a namespace, which allows an hierarchical fallback model. For instance, logging information for the type “Company.Product.Layer2.Internals” will be send to the WindowsEventLogLoggginProvider named “Company.Product.Layer2”. Logging information for the type “Company.Product.Layer3.Helpers” however, will be logged to the WindowsEventLogLoggginProvider named “Company.Product”, because there is no “Company.Product.Layer3” configured.
  • The example shows how a CompositeLoggingProvider can be used to forward logging information to multiple other providers that might have other filtering level for events defined.

More information

For more information about CuttingEdge.Logging, please visit the following links:

Last edited Aug 27, 2010 at 8:18 AM by dot_NET_Junkie, version 2