Created
January 30, 2011 02:08
-
-
Save oillio/802435 to your computer and use it in GitHub Desktop.
A simple wrappert to convert a log4net ILog into a ReactiveUI ILog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using log4net.Core; | |
using ReactiveUI; | |
namespace Logger { | |
public class log4netLogger : ILog { | |
private readonly log4net.ILog _log; | |
public log4netLogger(string prefix) | |
{ | |
_log = log4net.LogManager.GetLogger(prefix); | |
} | |
public LogLevel CurrentLogLevel { | |
get { | |
var level = _log.Logger.Repository.Threshold; | |
if (level == Level.Debug) return LogLevel.Debug; | |
if (level == Level.Info) return LogLevel.Info; | |
if (level == Level.Warn) return LogLevel.Warn; | |
if (level == Level.Error) return LogLevel.Error; | |
return LogLevel.Fatal; | |
} | |
set { | |
//log4net does not have a log level for the individua loggers. | |
//Set the levels and filters in the log4net configuration. | |
} | |
} | |
/* | |
* Extremely boring code ahead | |
*/ | |
#region This code is extremely dull | |
public void Debug(object message) { _log.Debug(message); } | |
public void Debug(object message, Exception exception) { _log.Debug(message, exception); } | |
public void DebugFormat(string format, params object[] args) { _log.DebugFormat(format, args); } | |
public void DebugFormat(IFormatProvider provider, string format, params object[] args) { _log.DebugFormat(provider, format, args); } | |
public void DebugFormat(string format, object arg0) { _log.DebugFormat(format, arg0); } | |
public void DebugFormat(string format, object arg0, object arg1) { _log.DebugFormat(format, arg0, arg1); } | |
public void DebugFormat(string format, object arg0, object arg1, object arg2) { _log.DebugFormat(format, arg0, arg1, arg2); } | |
public void Warn(object message) { _log.Warn(message); } | |
public void Warn(object message, Exception exception) { _log.Warn(message, exception); } | |
public void WarnFormat(string format, params object[] args) { _log.WarnFormat(format, args); } | |
public void WarnFormat(IFormatProvider provider, string format, params object[] args) { _log.WarnFormat(format, args, provider); } | |
public void WarnFormat(string format, object arg0) { _log.WarnFormat(format, arg0); } | |
public void WarnFormat(string format, object arg0, object arg1) { _log.WarnFormat(format, arg0, arg1); } | |
public void WarnFormat(string format, object arg0, object arg1, object arg2) { _log.WarnFormat(format, arg0, arg1, arg2); } | |
public void Info(object message) { _log.Info(message); } | |
public void Info(object message, Exception exception) { _log.Info(message, exception); } | |
public void InfoFormat(string format, params object[] args) { _log.InfoFormat(format, args); } | |
public void InfoFormat(IFormatProvider provider, string format, params object[] args) { _log.InfoFormat(format, args, provider); } | |
public void InfoFormat(string format, object arg0) { _log.InfoFormat(format, arg0); } | |
public void InfoFormat(string format, object arg0, object arg1) { _log.InfoFormat(format, arg0, arg1); } | |
public void InfoFormat(string format, object arg0, object arg1, object arg2) { _log.InfoFormat(format, arg0, arg1, arg2); } | |
public void Error(object message) { _log.Error(message); } | |
public void Error(object message, Exception exception) { _log.Error(message, exception); } | |
public void ErrorFormat(string format, params object[] args) { _log.ErrorFormat(format, args); } | |
public void ErrorFormat(IFormatProvider provider, string format, params object[] args) { _log.ErrorFormat(format, args, provider); } | |
public void ErrorFormat(string format, object arg0) { _log.ErrorFormat(format, arg0); } | |
public void ErrorFormat(string format, object arg0, object arg1) { _log.ErrorFormat(format, arg0, arg1); } | |
public void ErrorFormat(string format, object arg0, object arg1, object arg2) { _log.ErrorFormat(format, arg0, arg1, arg2); } | |
public void Fatal(object message) { _log.Fatal(message); } | |
public void Fatal(object message, Exception exception) { _log.Fatal(message, exception); } | |
public void FatalFormat(string format, params object[] args) { _log.FatalFormat(format, args); } | |
public void FatalFormat(IFormatProvider provider, string format, params object[] args) { _log.FatalFormat(format, args, provider); } | |
public void FatalFormat(string format, object arg0) { _log.FatalFormat(format, arg0); } | |
public void FatalFormat(string format, object arg0, object arg1) { _log.FatalFormat(format, arg0, arg1); } | |
public void FatalFormat(string format, object arg0, object arg1, object arg2) { _log.FatalFormat(format, arg0, arg1, arg2); } | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment