Skip to content

Instantly share code, notes, and snippets.

@ianoxley
Created August 6, 2009 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianoxley/163322 to your computer and use it in GitHub Desktop.
Save ianoxley/163322 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Github.Gist.Logging {
public interface ILogger {
void Warn(string s);
void Warn(string s, Exception ex);
void WarnFormat(string s, params object [] args);
void Info(string s);
void Info(string s, Exception ex);
void InfoFormat(string s, params object[] args);
void Debug(string s);
void Debug(string s, Exception ex);
void DebugFormat(string s, params object[] args);
}
}
using System;
using log4net;
using System.Reflection;
namespace Github.Gist.Logging {
/// <summary>
/// log4net wrapper to allow easier unit testing (by testing against the ILogger interface)
/// </summary>
public class Log4NetLogger : ILogger {
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
#region ILogger Members
public void Warn(string s) {
Log.Warn(s);
}
public void Warn(string s, Exception ex) {
Log.Warn(s, ex);
}
public void WarnFormat(string s, params object [] args) {
Log.WarnFormat(s, args);
}
public void Info(string s) {
Log.Info(s);
}
public void Info(string s, Exception ex) {
Log.Info(s, ex);
}
public void InfoFormat(string s, params object[] args) {
Log.InfoFormat(s, args);
}
public void Debug(string s) {
Log.Debug(s);
}
public void Debug(string s, Exception ex) {
Log.Debug(s, ex);
}
public void DebugFormat(string s, params object[] args) {
Log.DebugFormat(s, args);
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment