我有以下界面:
public interface ILogger
{
void Debug(string message, params object[] values);
void Info(string message, params object[] values);
void Warn(string message, params object[] values);
void Error(string message, params object[] values);
void Fatal(string message, params object[] values);
}
Run Code Online (Sandbox Code Playgroud)
以及以下实施:
public class Log4netLogger : ILogger
{
private ILog _log;
public Log4netLogger(Type type)
{
_log = LogManager.GetLogger(type);
}
public void Debug(string message, params object[] values)
{
_log.DebugFormat(message, values);
}
// other logging methods here...
}
Run Code Online (Sandbox Code Playgroud)
我的想法是使用structuremap使用执行日志记录的类的Type来实例化Log4netLogger类.但是,我不能为我的生活弄清楚如何将调用类的类型传递给structuremap,以便它可以传递给日志记录实现的构造函数.关于如何做到这一点(或更好的方式)的任何建议都将是最受欢迎的.