本文整理汇总了C#中ILog.WarnFormat方法的典型用法代码示例。如果您正苦于以下问题:C# ILog.WarnFormat方法的具体用法?C# ILog.WarnFormat怎么用?C# ILog.WarnFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILog
的用法示例。
在下文中一共展示了ILog.WarnFormat方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: WarnWhenGreaterThan
public static void WarnWhenGreaterThan(this TimeSpan timespan, TimeSpan maximumTimeSpan, string messageFormat, ILog log)
{
if (timespan < maximumTimeSpan)
{
return;
}
if (messageFormat.Contains("{milliseconds}", StringComparison.CurrentCultureIgnoreCase))
{
log.WarnFormat(messageFormat.Replace("{milliseconds}", "{0:N0}"), timespan.TotalMilliseconds);
}
else
{
log.WarnFormat(messageFormat, timespan);
}
}
示例3: LogFormat
public static void LogFormat(this IEnableLog This, ILog logger, LogType type, string format, params object[] args)
{
switch (type)
{
case LogType.Debug:
logger.DebugFormat(format, args);
break;
case LogType.Error:
logger.ErrorFormat(format, args);
break;
case LogType.Fatal:
logger.FatalFormat(format, args);
break;
case LogType.Info:
logger.InfoFormat(format, args);
break;
case LogType.Warn:
logger.WarnFormat(format, args);
break;
}
}
示例4: CloudProvisioning
/// <summary>IoC constructor.</summary>
public CloudProvisioning(ICloudConfigurationSettings settings, ILog log, ICloudProvisioningObserver provisioningObserver = null)
{
_log = log;
// try get settings and certificate
if (!CloudEnvironment.IsAvailable)
{
_log.WarnFormat("Provisioning: RoleEnvironment not available on worker {0}.", CloudEnvironment.PartitionKey);
return;
}
var currentDeploymentPrivateId = CloudEnvironment.AzureDeploymentId;
Maybe<X509Certificate2> certificate = Maybe<X509Certificate2>.Empty;
if (!String.IsNullOrWhiteSpace(settings.SelfManagementCertificateThumbprint))
{
certificate = CloudEnvironment.GetCertificate(settings.SelfManagementCertificateThumbprint);
}
// early evaluate management status for intrinsic fault states, to skip further processing
if (!currentDeploymentPrivateId.HasValue || !certificate.HasValue || string.IsNullOrWhiteSpace(settings.SelfManagementSubscriptionId))
{
_log.DebugFormat("Provisioning: Not available because either the certificate or the subscription was not provided correctly.");
return;
}
// detect dev fabric
if (currentDeploymentPrivateId.Value.StartsWith("deployment("))
{
_log.DebugFormat("Provisioning: Not available in dev fabric instance '{0}'.", CloudEnvironment.AzureCurrentInstanceId.GetValue("N/A"));
return;
}
// ok
_provisioning = new AzureProvisioning(settings.SelfManagementSubscriptionId, certificate.Value, provisioningObserver);
_currentDeployment = new AzureCurrentDeployment(currentDeploymentPrivateId.Value, settings.SelfManagementSubscriptionId, certificate.Value, provisioningObserver);
}
示例5: 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(()=>{});
}
示例6: DefaultWriteLogEvent
protected static void DefaultWriteLogEvent(ILog commonLog, TraceEventType traceEventType, String message, Exception ex)
{
switch (traceEventType)
{
case TraceEventType.Critical:
commonLog.FatalFormat(message, ex);
break;
case TraceEventType.Error:
commonLog.ErrorFormat(message, ex);
break;
case TraceEventType.Warning:
commonLog.WarnFormat(message, ex);
break;
case TraceEventType.Information:
commonLog.InfoFormat(message, ex);
break;
case TraceEventType.Verbose:
commonLog.TraceFormat(message, ex);
break;
case TraceEventType.Start:
commonLog.DebugFormat(message, ex);
break;
case TraceEventType.Stop:
commonLog.DebugFormat(message, ex);
break;
case TraceEventType.Suspend:
commonLog.DebugFormat(message, ex);
break;
case TraceEventType.Resume:
commonLog.DebugFormat(message, ex);
break;
case TraceEventType.Transfer:
commonLog.DebugFormat(message, ex);
break;
default:
throw new ArgumentOutOfRangeException("traceEventType");
}
}
示例7: CanLogMessageWithException
protected virtual void CanLogMessageWithException(ILog log)
{
log.TraceFormat("Hi {0}", new ArithmeticException(), "dude");
log.DebugFormat("Hi {0}", new ArithmeticException(), "dude");
log.InfoFormat("Hi {0}", new ArithmeticException(), "dude");
log.WarnFormat("Hi {0}", new ArithmeticException(), "dude");
log.ErrorFormat("Hi {0}", new ArithmeticException(), "dude");
log.FatalFormat("Hi {0}", new ArithmeticException(), "dude");
}