0 people following this project (follow)

Project Description
.NETLib Logging is an easy to use library that utilizes extension methods to provide a clean and easy to use API to log Exceptions.

You'll no longer to have to wonder why after compiling you have all the empty catch blocks.

Developed in C#

- Often developers are found leaving open try { } catch(Exception ex){ } blocks. The need for an easy to use logging library was needed and thus, .NetLib.Log was born.
- Recently added very simple SQL Logging, it requires the developer to setup a connection string in the App/Web.config

Usage example : Logging Library

ILog log = new FileLog();
log.Write("This is a File Log");

log = new SQLLog();
log.Write("This is a SQL Log");

log = new EventLog()
log.Write("This is an Event Log");

Usage example : Exceptions

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NetLib.Log.Debug
{
	public static class Program
	{
		public static void Main(string[] args)
		{
			try
			{
				int x = 0;
				int y = 5 / x;
			}
			catch (Exception ex)
			{
				ex.Log(); //or
				ex.Log(false); //to not include the stack trace
			}
		}
	}
}

Application Configuration File

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<configSections>
		<section name="NetLib.Log" type="NetLib.Log.ConfigSection, NetLib.Log"/>
	</configSections>
	<NetLib.Log>
		<Destinations LogDirectory="Logs">
			<add Destination="NetLib.Log.FileLog"/>
			<add Destination="NetLib.Log.SQLLog"/>
		</Destinations>
	</NetLib.Log>
	<connectionStrings>
		<add name="Exception" connectionString="Data Source=.; Initial Catalog=Budget; User ID=sa; Password=sa;"/>
	</connectionStrings>
</configuration>

Additional "Loggers" can be included by implementing the ILog interface. This will allow developers to further extend NetLib.Log to include their favourite destinations for logging. i.e. mySQL.

Last edited Sep 4 2009 at 4:08 AM by pieterg, version 14