当前位置: 首页>>代码示例>>C#>>正文


C# ILog.WarnFormat方法代码示例

本文整理汇总了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");
        }
开发者ID:afyles,项目名称:NServiceBus,代码行数:28,代码来源:BaseLoggerFactoryTests.cs

示例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);
            }
        }
开发者ID:OpenMagic,项目名称:OpenMagic,代码行数:16,代码来源:TimeSpanExtensions.cs

示例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;
     }
 }
开发者ID:KyleGobel,项目名称:Deerso.Logging,代码行数:21,代码来源:IEnableLog.cs

示例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);
        }
开发者ID:alexmg,项目名称:lokad-cloud,代码行数:37,代码来源:CloudProvisioning.cs

示例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(()=>{});

        }
开发者ID:netcasewqs,项目名称:nlite,代码行数:36,代码来源:LoggerTest.cs

示例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");
     }
 }
开发者ID:richarddbarnett,项目名称:Owin.Logging.Common,代码行数:38,代码来源:CommonLoggingFactory.cs

示例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");
 }
开发者ID:briandealwis,项目名称:gt,代码行数:9,代码来源:AbstractSimpleLogTest.cs


注:本文中的ILog.WarnFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。