public void Log <TException>(LogLevel logLevel, Func <string> messageFunc, TException exception) where TException : Exception { switch (logLevel) { case LogLevel.Debug: if (DynamicHelper.GetPropertyValue <bool>(m_logger, "IsDebugEnabled")) { DynamicHelper.InvokeMethod(m_logger, "DebugException", messageFunc(), exception); } break; case LogLevel.Information: if (DynamicHelper.GetPropertyValue <bool>(m_logger, "IsInfoEnabled")) { DynamicHelper.InvokeMethod(m_logger, "InfoException", messageFunc(), exception); } break; case LogLevel.Warning: if (DynamicHelper.GetPropertyValue <bool>(m_logger, "IsWarnEnabled")) { DynamicHelper.InvokeMethod(m_logger, "WarnException", messageFunc(), exception); } break; case LogLevel.Error: if (DynamicHelper.GetPropertyValue <bool>(m_logger, "IsErrorEnabled")) { DynamicHelper.InvokeMethod(m_logger, "ErrorException", messageFunc(), exception); } break; case LogLevel.Fatal: if (DynamicHelper.GetPropertyValue <bool>(m_logger, "IsFatalEnabled")) { DynamicHelper.InvokeMethod(m_logger, "FatalException", messageFunc(), exception); } break; default: if (DynamicHelper.GetPropertyValue <bool>(m_logger, "IsTraceEnabled")) { DynamicHelper.InvokeMethod(m_logger, "TraceException", messageFunc(), exception); } break; } }
public void Log(LogLevel logLevel, Func <string> messageFunc) { switch (logLevel) { case LogLevel.Information: if (DynamicHelper.GetPropertyValue <bool>(m_logger, "IsInfoEnabled")) { DynamicHelper.InvokeMethod(m_logger, "Info", messageFunc()); } break; case LogLevel.Warning: if (DynamicHelper.GetPropertyValue <bool>(m_logger, "IsWarnEnabled")) { DynamicHelper.InvokeMethod(m_logger, "Warn", messageFunc()); } break; case LogLevel.Error: if (DynamicHelper.GetPropertyValue <bool>(m_logger, "IsErrorEnabled")) { DynamicHelper.InvokeMethod(m_logger, "Error", messageFunc()); } break; case LogLevel.Fatal: if (DynamicHelper.GetPropertyValue <bool>(m_logger, "IsFatalEnabled")) { DynamicHelper.InvokeMethod(m_logger, "Fatal", messageFunc()); } break; default: if (DynamicHelper.GetPropertyValue <bool>(m_logger, "IsDebugEnabled")) { DynamicHelper.InvokeMethod(m_logger, "Debug", messageFunc()); // Log4Net doesn't have a 'Trace' level, so all Trace messages are written as 'Debug' } break; } }