Click here to Skip to main content
15,891,316 members
Articles / Programming Languages / C#

An Introduction to the log4net logging library, using C# - Part 2

Rate me:
Please Sign up or sign in to vote.
4.52/5 (38 votes)
12 Sep 20043 min read 250.8K   2.6K   85  
An article describing more basic use of the log4net library.
using log4net;
using log4net.Config;

public class LogTest3
{
	private static readonly ILog logger = LogManager.GetLogger(typeof(LogTest3));
	
	static LogTest3()
	{
		DOMConfigurator.Configure();
	}

	static void Main(string[] args)
	{
		LogTest3 log3 = new LogTest3();
		log3.DoLogging();
		LogTest4 log4 = new LogTest4();
		log4.DoLogging();
	}
	
	public void DoLogging()
	{
		logger.Debug("Here is a debug log from LogTest3.");
		logger.Info("... and an Info log from LogTest3.");
	}
}

public class LogTest4
{
	private static readonly ILog logger = LogManager.GetLogger(typeof(LogTest4));
	
	static LogTest4()
	{
		DOMConfigurator.Configure();
	}

	public void DoLogging()
	{
		logger.Debug("Here is a debug log from LogTest4.");
		logger.Info("... and an Info log from LogTest4.");
	}

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions