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


C# ILog.Warn方法代码示例

本文整理汇总了C#中ILog.Warn方法的典型用法代码示例。如果您正苦于以下问题:C# ILog.Warn方法的具体用法?C# ILog.Warn怎么用?C# ILog.Warn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILog的用法示例。


在下文中一共展示了ILog.Warn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: GetXmppHosts

 public XmppHost[] GetXmppHosts(IPAddress[] dnsServers, string domain, ILog log)
 {
     var dnsQueryRequest = new DnsQueryRequest();
     string record = "_xmpp-server._tcp." + domain;
     bool dnsServerWasReached = false;
     foreach (IPAddress address in dnsServers) {
         DnsQueryResponse queryResponse = null;
         try {
             queryResponse = dnsQueryRequest.Resolve(address.ToString(), record, NsType.SRV, NsClass.INET, ProtocolType.Udp);
         }
         catch(SocketException ex) {
             log.Error("Dns server unreachable. " + ex);
             continue;
         }
         dnsServerWasReached = true;
         if (queryResponse == null || queryResponse.Answers == null || queryResponse.Answers.Length <= 0) continue;
         var hosts = new List<XmppHost>();
         foreach (IDnsRecord answer in queryResponse.Answers) {
             var srvRecord = (SrvRecord) answer;
             try {
                 IPHostEntry ipHostEntry = System.Net.Dns.GetHostEntry(srvRecord.HostName);
                 foreach (IPAddress ipAddress in ipHostEntry.AddressList) {
                     hosts.Add(new XmppHost(ipHostEntry.HostName, ipAddress, srvRecord.Port));
                 }
             }
             catch (SocketException ex) {
                 if (ex.SocketErrorCode == SocketError.HostNotFound) {
                     log.Warn(ex);
                 }
                 else {
                     throw;
                 }
             }
             catch (Exception ex) {
                 log.Error(ex);
                 throw;
             }
         }
         if(hosts.Count == 0) {
             throw new SocketException(11001); //Host not found
         }
         return hosts.ToArray();
     }
     if (!dnsServerWasReached) {
         throw new SocketException(10060);
     }
     //couldn't locate the service via dns, assume the domain is the host.
     try {
         IPHostEntry defaultHostEntry = System.Net.Dns.GetHostEntry(domain);
         var hosts = new List<XmppHost>();
         foreach (IPAddress ipAddress in defaultHostEntry.AddressList) {
             hosts.Add(new XmppHost(defaultHostEntry.HostName, ipAddress, 5222)); //5222 default XmppPort
         }
         return hosts.ToArray();
     }
     catch(SocketException ex) {
         log.Error(ex);
         throw;
     }
 }
开发者ID:Andrea,项目名称:nxmpp,代码行数:60,代码来源:XmppHostsLookup.cs

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

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

示例4: OpenWebPage

        public static void OpenWebPage(string url, ILog logger)
        {
            try
            {
                Process.Start(url);
            }
            catch (Exception ex)
            {
                logger.Warn("Failed opening page: " + url, ex);

                string errorMessage = String.Format(HudsonTrayTrackerResources.ErrorBoxMessage, ex.Message);
                XtraMessageBox.Show(errorMessage, HudsonTrayTrackerResources.ErrorBoxCaption,
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
开发者ID:ViniciusConsultor,项目名称:hudson-tray-tracker,代码行数:15,代码来源:UIUtils.cs

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

示例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;
     }
 }
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:46,代码来源:SimpleLoggingAdvice.cs

示例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;
     }
 }
开发者ID:NetUtil,项目名称:Util,代码行数:23,代码来源:Warning.cs

示例8: ConfigurePath

 public static void ConfigurePath(Options options, ILog logger)
 {
     if (!string.IsNullOrWhiteSpace(options.WorkingDirectory))
     {
         if (!Directory.Exists(options.WorkingDirectory))
         {
             logger.Warn(string.Format("Could not find specified working directory {0}. Defaulting to current directory", options.WorkingDirectory));
         }
         else
         {
             Directory.SetCurrentDirectory(options.WorkingDirectory);
         }
     }
 }
开发者ID:jvanzella,项目名称:mmbot,代码行数:14,代码来源:Initializer.cs

示例9: LoadScripts

 private static void LoadScripts(Options options, Robot robot, NuGetPackageAssemblyResolver nugetResolver,
     ILog logger)
 {
     if (options.Test)
     {
         robot.AutoLoadScripts = false;
         options.ScriptFiles.ForEach(robot.LoadScriptFile);
     }
     else
     {
         robot.LoadScripts(nugetResolver.GetCompiledScriptsFromPackages());
         if (!Directory.Exists(Path.Combine(Environment.CurrentDirectory, "scripts")))
         {
             logger.Warn(
                 "There is no scripts folder. Have you forgotten to run 'mmbot init' to initialise the current running directory?");
         }
     }
 }
开发者ID:jamessantiago,项目名称:mmbot,代码行数:18,代码来源:Initializer.cs

示例10: LoadAdapters

        internal static Type[] LoadAdapters(NuGetPackageAssemblyResolver nugetResolver, ILog logger)
        {
            var adapters = nugetResolver.GetCompiledAdaptersFromPackages().ToArray();

            if (!adapters.Any())
            {
                logger.Warn("Could not find any adapters. Loading the default console adapter only");
            }
            return adapters;
        }
开发者ID:jamessantiago,项目名称:mmbot,代码行数:10,代码来源:Initializer.cs

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

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

示例13: WebSupportModule

        /// <summary>
        /// For webapplications always
        /// <ul>
        /// <li>convert IResources using the current context.</li>
        /// <li>use "web" as default resource protocol</li>
        /// <li>use <see cref="HybridContextStorage"/> as default threading storage</li>
        /// </ul>
        /// </summary>
        static WebSupportModule()
        {
            s_log = LogManager.GetLogger(typeof(WebSupportModule));

            // required to enable accessing HttpContext.Request during IHttpModule.Init() in integrated mode
            ContextHideRequestResponse = null;
            try
            {
                fiHideRequestResponse = typeof(HttpContext).GetField("HideRequestResponse", BindingFlags.Instance|BindingFlags.NonPublic);
//                fiHideRequestResponse.SetValue(HttpContext.Current, false);
                ContextHideRequestResponse = (fiHideRequestResponse!=null)?new SafeField(fiHideRequestResponse):null;
            }
            catch(SecurityException sec)
            {
                s_log.Warn(string.Format("failed reflecting field HttpContext.HideRequestResponse due to security restrictions {0}", sec));
            }

            // register additional resource handler
            ResourceHandlerRegistry.RegisterResourceHandler(WebUtils.DEFAULT_RESOURCE_PROTOCOL, typeof(WebResource));
            // replace default IResource converter
            TypeConverterRegistry.RegisterConverter(typeof(IResource),
                                                    new ResourceConverter(
                                                        new ConfigurableResourceLoader(WebUtils.DEFAULT_RESOURCE_PROTOCOL)));
            // default to hybrid thread storage implementation
            LogicalThreadContext.SetStorage(new HybridContextStorage());

            s_log.Debug("Set default resource protocol to 'web' and installed HttpContext-aware HybridContextStorage");
        }
开发者ID:chadsowald,项目名称:spring-net,代码行数:36,代码来源:WebSupportModule.cs

示例14: Send

    public async Task<bool> Send(LeadConduit.Interface.Models.VehicleProvider vp, Lead lead, ILog log)
    {
      bool result = false;
      string jsonLead = JsonConvert.SerializeObject(lead);
      AccessorResponse<InventoryItem> GIAccessorResponse = GlobalInventoryAccessor.Inventory.Retrieve((int)lead.GlobalInventoryId, lead.GlobalInventorySourceId);
      ParameterData parameterData = JsonSerializer.CreateDefault().Deserialize<ParameterData>(new JsonTextReader(new StringReader(vp.Parameters)));
      if (GIAccessorResponse != null && GIAccessorResponse.Success && GIAccessorResponse.Result.GlobalInventoryId != null)
      {
        if (GIAccessorResponse.Result.Detail != null)
        {
          //deserialize tag and use for token values into dictionary
          Dictionary<string, string> tokenValues = new Dictionary<string, string>()
          {
            {Tokens.DealixLead.LeadID,  lead.Id.ToString() },
            {Tokens.DealixLead.DateTime, lead.DateCreated.ToString()},
            {Tokens.DealixLead.ThirdPartyFeedID, ""}, //lead.ThirdPartyFeedID
            {Tokens.DealixLead.VIN, GIAccessorResponse.Result.Detail.VIN.ToString()},
            {Tokens.DealixLead.SenderFirstName, lead.FirstName},
            {Tokens.DealixLead.SenderLastName, lead.LastName},
            {Tokens.DealixLead.SenderEmailAddress, lead.EmailAddress},
            {Tokens.DealixLead.SenderPhone, lead.Phone},
            {Tokens.DealixLead.SenderCity, lead.City},
            {Tokens.DealixLead.SenderLocation, lead.LocationAbbr},
            {Tokens.DealixLead.SenderZipcode, lead.ZipCode},
            {Tokens.DealixLead.SenderComments, lead.Comments}
          };
          List<CFS.MessageCannon.V2.Interface.Contact> contacts = new List<CFS.MessageCannon.V2.Interface.Contact>() { new CFS.MessageCannon.V2.Interface.Contact { EmailAddress = lead.EmailAddress } };
          //open xml file and replace [[token]] with values
          
          string fileName = Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), "Assets", "DealixLeadTemplate.xml");
          FileStream xmlFile = File.Open(fileName, FileMode.Open);
          StreamReader rdr = new StreamReader(xmlFile);
          string xmlText = rdr.ReadToEnd();
          rdr.Close();
          xmlFile.Close();
          foreach (var item in tokenValues)
          {
            xmlText = xmlText.Replace(item.Key, item.Value);
          }
          //send xmlText to url 
          string responseText = null;
          string postUrl = "https://www.awesomecustomsite.com/FormFeed.aspx";
          string postData = String.Format("xml={0}", HttpUtility.UrlEncode(xmlText));
          byte[] formData = Encoding.UTF8.GetBytes(postData);

          HttpContent content = new ByteArrayContent(formData);

          content.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

          HttpClient client = new HttpClient();

          using (var response = client.PostAsync(new Uri(postUrl), content).Result)
          {
            result = verifyResponseCode(response, log);
            if (result)
            {
              log.Info(typeof(DealixLeadSender).Name, "Lead #{0} sent successfully.", lead.Id);
            }
            else
            {
              log.Warn(typeof(DealixLeadSender).Name, "Lead #{0} FAILED to send.", lead.Id);
              log.Warn(typeof(DealixLeadSender).Name, "Lead data sent to handler:\r\n{0}", jsonLead);
            }

          }
        }
      }


      return result;
    }
开发者ID:benpetersen,项目名称:Portfolio,代码行数:71,代码来源:DealixLeadSender.cs

示例15: 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;
     }
 }
开发者ID:netcasewqs,项目名称:nlite,代码行数:21,代码来源:LoggerInterceptor.cs


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