Skip to content
smhinsey edited this page Dec 4, 2011 · 4 revisions

Summary

Euclid defines a straightforward common logging mechanism. Any object which implements the ILoggingSource marker interface has a series of extension methods available to it.

TODO: Add several default custom object renderers for log4net.

Location

Defined in the Euclid.Common project with a default implementation provided in Euclid.Common.Logging project.

Usage

Your application must configure log4net on startup using BasicConfigurator.Configure(), XmlConfigurator.Configure() or a similar call.

Within your application you can use the logger from any type that inherits from ILoggingSource. The this qualifier is necessary in order for the compiler to resolve the extension method.

	namespace MyProject
	{
		public class MyFeature : ILoggingSource
		{
			public void DoSomething()
			{
				this.WriteInfoMessage("I've done something!")
			}
		}
	}

When run using the BasicConfigurator, the above would produce the following output on the console.

8494 [10] INFO MyProject.MyFeature (null) - I've done something!

The following logging methods are available.

	public void WriteInfoMessage(string message)
	public void WriteDebugMessage(string message)
	public void WriteWarnMessage(string message)
	public void WriteErrorMessage(string message, Exception exception)
	public void WriteFatalMessage(string message, Exception exception)