本文整理汇总了C#中ILog.Fatal方法的典型用法代码示例。如果您正苦于以下问题:C# ILog.Fatal方法的具体用法?C# ILog.Fatal怎么用?C# ILog.Fatal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILog
的用法示例。
在下文中一共展示了ILog.Fatal方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CallAllMethodsOnLog
protected void CallAllMethodsOnLog(ILog log)
{
Assert.IsTrue(log.IsDebugEnabled);
Assert.IsTrue(log.IsErrorEnabled);
Assert.IsTrue(log.IsFatalEnabled);
Assert.IsTrue(log.IsInfoEnabled);
Assert.IsTrue(log.IsWarnEnabled);
log.Debug("Testing DEBUG");
log.Debug("Testing DEBUG Exception", new Exception());
log.DebugFormat("Testing DEBUG With {0}", "Format");
log.Info("Testing INFO");
log.Info("Testing INFO Exception", new Exception());
log.InfoFormat("Testing INFO With {0}", "Format");
log.Warn("Testing WARN");
log.Warn("Testing WARN Exception", new Exception());
log.WarnFormat("Testing WARN With {0}", "Format");
log.Error("Testing ERROR");
log.Error("Testing ERROR Exception", new Exception());
log.ErrorFormat("Testing ERROR With {0}", "Format");
log.Fatal("Testing FATAL");
log.Fatal("Testing FATAL Exception", new Exception());
log.FatalFormat("Testing FATAL With {0}", "Format");
}
示例2: AccessException
public static void AccessException(this IIdempotenceService service, ILog log, Exception ex, ObservablePipeline pipeline)
{
Guard.AgainstNull(service, "service");
Guard.AgainstNull(log, "log");
Guard.AgainstNull(ex, "ex");
Guard.AgainstNull(pipeline, "pipeline");
log.Fatal(string.Format( ESBResources.FatalIdempotenceServiceException, service.GetType().FullName, ex.CompactMessages()));
pipeline.Abort();
}
示例3: InternalTest
private static void InternalTest(ILog log)
{
const string message = "add record in db";
log.Debug(message);
log.Debug(message, new Exception());
log.DebugFormat(message);
log.Error(message);
log.Error(message, new Exception());
log.ErrorFormat(message);
log.Fatal(message);
log.Fatal(message, new Exception());
log.Info(message);
log.Info(message, new Exception());
log.InfoFormat(message);
log.Warn(message);
log.Warn(message, new Exception());
log.WarnFormat(message);
Console.WriteLine(log.IsDebugEnabled);
Console.WriteLine(log.IsErrorEnabled);
Console.WriteLine(log.IsFatalEnabled);
Console.WriteLine(log.IsInfoEnabled);
Console.WriteLine(log.IsWarnEnabled);
//log.TryLogFail(ErrorAction).Exception(e => Console.WriteLine(e.Message));
//log.TryLogFail(SuccessAction).Success(()=>{});
}
示例4: AccessDenied
public static void AccessDenied(ILog log, string path)
{
Guard.AgainstNull(log, "log");
Guard.AgainstNull(path, "path");
log.Fatal(
string.Format(
MsmqResources.AccessDenied,
WindowsIdentity.GetCurrent() != null
? WindowsIdentity.GetCurrent().Name
: MsmqResources.Unknown,
path));
if (Environment.UserInteractive)
{
return;
}
Process.GetCurrentProcess().Kill();
}
示例5: Log
public static void Log(this IEnableLog This, LogType type, object message, ILog logger = null)
{
logger = logger ?? LogManager.GetLogger(This.GetType());
switch (type)
{
case LogType.Debug:
logger.Debug(message);
break;
case LogType.Error:
logger.Error(message);
break;
case LogType.Fatal:
logger.Fatal(message);
break;
case LogType.Info:
logger.Info(message);
break;
case LogType.Warn:
logger.Warn(message);
break;
}
}
示例6: WriteToLog
private void WriteToLog(LogLevel logLevel, ILog log, string text, Exception e)
{
switch (logLevel)
{
case LogLevel.All:
case LogLevel.Trace:
if (log.IsTraceEnabled)
{
if (e == null) log.Trace(text); else log.Trace(text, e);
}
break;
case LogLevel.Debug:
if (log.IsDebugEnabled)
{
if (e == null) log.Debug(text); else log.Debug(text, e);
}
break;
case LogLevel.Error:
if (log.IsErrorEnabled)
{
if (e == null) log.Error(text); else log.Error(text, e);
}
break;
case LogLevel.Fatal:
if (log.IsFatalEnabled)
{
if (e == null) log.Fatal(text); else log.Fatal(text, e);
}
break;
case LogLevel.Info:
if (log.IsInfoEnabled)
{
if (e == null) log.Info(text); else log.Info(text, e);
}
break;
case LogLevel.Warn:
if (log.IsWarnEnabled)
{
if (e == null) log.Warn(text); else log.Warn(text, e);
}
break;
case LogLevel.Off:
default:
break;
}
}
示例7: WriteLog
/// <summary>
/// 写日志
/// </summary>
/// <param name="log">日志组件</param>
public void WriteLog( ILog log ) {
switch ( Level ) {
case LogLevel.Debug:
log.Debug();
break;
case LogLevel.Information:
log.Info();
break;
case LogLevel.Warning:
log.Warn();
break;
case LogLevel.Error:
log.Error();
break;
case LogLevel.Fatal:
log.Fatal();
break;
}
}
示例8: CanLogMessageWithException
protected virtual void CanLogMessageWithException(ILog log)
{
log.Trace(m => m("Hi {0}", "dude"));
log.Debug(m => m("Hi {0}", "dude"), new ArithmeticException());
log.Info(m => m("Hi {0}", "dude"), new ArithmeticException());
log.Warn(m => m("Hi {0}", "dude"), new ArithmeticException());
log.Error(m => m("Hi {0}", "dude"), new ArithmeticException());
log.Fatal(m => m("Hi {0}", "dude"), new ArithmeticException());
}
示例9: CanLogMessage
protected virtual void CanLogMessage(ILog log)
{
log.TraceFormat("Hi");
log.Debug("Hi");
log.Info("Hi");
log.Warn("Hi");
log.Error("Hi");
log.Fatal("Hi");
}
示例10: Log
private void Log(ILog logger, string message)
{
switch (Level)
{
case LogLevel.Debug:
logger.Debug(message);
break;
case LogLevel.Error:
logger.Error(message);
break;
case LogLevel.Fatal:
logger.Fatal(message);
break;
case LogLevel.Info:
logger.Info(message);
break;
case LogLevel.Warn:
logger.Warn(message);
break;
}
}
示例11: Log
/**
* Logs the exception to the appropriate log level if the exception is annotated with
* <code>@RestrictedLevel</code>. Otherwise log normally.
* @param log the logger
* @param logLevel the desired log level
* @param message the error message
* @param t the exception
*/
private static void Log (ILog log, LogLevel logLevel, object message, Exception ex)
{
string theMessage = BuildExceptionMessage(Convert.ToString(message), ex);
if (logLevel.Equals(LogLevel.Fatal))
{
log.Fatal(theMessage, ex != null ? ex : null);
}
else if (logLevel.Equals(LogLevel.Error))
{
log.Error(theMessage, ex != null ? ex : null);
}
else if (logLevel.Equals(LogLevel.Warn))
{
log.Warn(theMessage, ex != null ? ex : null);
}
else if (logLevel.Equals(LogLevel.Info))
{
log.Info(theMessage, ex != null ? ex : null);
}
else if (logLevel.Equals(LogLevel.Debug))
{
log.Debug(theMessage, ex != null ? ex : null);
}
else if (logLevel.Equals(LogLevel.Trace))
{
//log.Trace(theMessage, ex != null ? ex : null);
log.Debug(theMessage, ex != null ? ex : null);
}
}