在下面的代码示例中,两种方法都被使用。这里有一个类似的问题here,但没有给出真正的解释,我也无法在帖子上发表评论。
public static partial class Log
{
private readonly static Type ThisDeclaringType = typeof(Log);
private static readonly ILogger defaultLogger;
private static readonly ILog defaultLog;
// Setup our default logger
static Log()
{
defaultLogger = LoggerManager.GetLogger(Assembly.GetCallingAssembly(), "CTWorkManager");
defaultLog = LogManager.GetLogger(Assembly.GetCallingAssembly(), "CTWorkManager");
}
public static void Info(object message)
{
if (defaultLogger.IsEnabledFor(Level.Info))
{
defaultLogger.Log(ThisDeclaringType, Level.Info, message, null);
}
if (defaultLog.IsInfoEnabled)
{
defaultLog.Info(message, null);
}
}
// etc...
}
}