Created
July 7, 2011 15:10
-
-
Save skalinets/1069722 to your computer and use it in GitHub Desktop.
This file contains 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
// declaration | |
public class ServiceLogger : IServiceLogger | |
{ | |
private readonly ILog log; | |
public ServiceLogger(object o) | |
{ | |
log = LogManager.GetLogger(o.GetType().Name); | |
} | |
public void Write(string message, params object[] args) | |
{ | |
log.InfoFormat(message, args); | |
} | |
public void WriteToExceptionCategory(string message, params object[] args) | |
{ | |
log.ErrorFormat(message, args); | |
} | |
} | |
public static class LoggerExtensions | |
{ | |
public static IServiceLogger GetLogger(this object o) | |
{ | |
return new ServiceLogger(o); | |
} | |
} | |
// usage | |
this.GetLogger().WriteToExceptionCategory("Error while opening connection: {0}", ex.Message); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment