當前位置: 首頁>>代碼示例>>C#>>正文


C# Logger.Warn方法代碼示例

本文整理匯總了C#中System.Logger.Warn方法的典型用法代碼示例。如果您正苦於以下問題:C# Logger.Warn方法的具體用法?C# Logger.Warn怎麽用?C# Logger.Warn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Logger的用法示例。


在下文中一共展示了Logger.Warn方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: LoggerGenerateOutputTest

        public void LoggerGenerateOutputTest()
        {
            Logger logger = new Logger(System.Reflection.Assembly.GetExecutingAssembly());
            logger.Exception("exception #1");
            logger.Exception("exception #2");
            logger.Exception("exception #3");
            logger.Exception("exception #4");

            logger.Error("Error 1");
            logger.Error("Error 2");
            logger.Error("Error 3");

            logger.Warn("Warn 1");
            logger.Warn("Warn 2");
            logger.Warn("Warn 3");

            string id = logger.LogResume();

            Assert.Pass(id);
        }
開發者ID:keboola,項目名稱:storage-api-dotnet-client,代碼行數:20,代碼來源:LoggerTest.cs

示例2: ExampleTwo

        private static void ExampleTwo()
        {
            var simpleLayout = new SimpleLayout();

            var consoleAppender = new ConsoleAppender(simpleLayout);
            var fileAppender = new FileAppender(simpleLayout);
            fileAppender.File = "log.txt";

            var logger = new Logger(consoleAppender, fileAppender);
            logger.Error("Error parsing JSON.");
            logger.Info(string.Format("User {0} successfully registered.", "Pesho"));
            logger.Warn("Warning - missing files.");
        }
開發者ID:nok32,項目名稱:SoftUny-HW,代碼行數:13,代碼來源:Program.cs

示例3: ExampleFour

        private static void ExampleFour()
        {
            var simpleLayout = new SimpleLayout();
            var consoleAppender = new ConsoleAppender(simpleLayout);
            consoleAppender.ReportLevel = ReportLevel.Error;

            var logger = new Logger(consoleAppender);

            logger.Info("Everything seems fine");
            logger.Warn("Warning: ping is too high - disconnect imminent");
            logger.Error("Error parsing request");
            logger.Critical("No connection string found in App.config");
            logger.Fatal("mscorlib.dll does not respond");
        }
開發者ID:nok32,項目名稱:SoftUny-HW,代碼行數:14,代碼來源:Program.cs

示例4: DispatchData

 public static void DispatchData(IDataProducer producer, object data, bool cloneDataOnFork, DispatchPolicy dispatchPolicy, 
     Set<IDataConsumer> dataConsumers, Logger logger)
 {
     if (data == null) { return; }
     if (dataConsumers.Count == 0)
     {
         if (logger != null) { logger.Warn("DispatchData", "Data ready but nobody is listening."); }
         return;
     }
     if (dispatchPolicy == DispatchPolicy.BalanceLoadSum || dispatchPolicy == DispatchPolicy.BalanceLoadMax)
     {
         if (logger != null) { logger.Trace("DispatchData", "Dispatching data of type {0} (load balancing) ...", data.GetType()); }
         int minLoad = int.MaxValue;
         IDataConsumer target = null;
         foreach (IDataConsumer consumer in dataConsumers)
         {
             int load = (dispatchPolicy == DispatchPolicy.BalanceLoadSum) ? GetBranchLoadSum(consumer) : GetBranchLoadMax(consumer);
             if (load < minLoad) { minLoad = load; target = consumer; }
         }
         target.ReceiveData(producer, data);
     }
     else if (dispatchPolicy == DispatchPolicy.Random)
     {
         if (logger != null) { logger.Trace("DispatchData", "Dispatching data of type {0} (random policy) ...", data.GetType()); }
         ArrayList<IDataConsumer> tmp = new ArrayList<IDataConsumer>(dataConsumers.Count);
         foreach (IDataConsumer dataConsumer in dataConsumers) { tmp.Add(dataConsumer); }
         tmp[mRandom.Next(0, tmp.Count)].ReceiveData(producer, data);
     }
     else
     {
         if (logger != null) { logger.Trace("DispatchData", "Dispatching data of type {0} (to-all policy) ...", data.GetType()); }
         if (dataConsumers.Count > 1 && cloneDataOnFork)
         {
             foreach (IDataConsumer dataConsumer in dataConsumers)
             {
                 dataConsumer.ReceiveData(producer, Utils.Clone(data, /*deepClone=*/true));
             }
         }
         else
         {
             foreach (IDataConsumer dataConsumer in dataConsumers)
             {
                 dataConsumer.ReceiveData(producer, data);
             }
         }
     }
     if (logger != null) { logger.Trace("DispatchData", "Data dispatched."); }
 }
開發者ID:viidea,項目名稱:latino,代碼行數:48,代碼來源:WorkflowUtils.cs

示例5: WlanClient

        public WlanClient()
        {
            ItsLogger = new Logger(this);

            try
            {
                Wlan.ThrowIfError(Wlan.WlanOpenHandle(1, IntPtr.Zero, out _negotiatedVersion, out _clientHandle));
                WlanNotificationCallback = new Wlan.WlanNotificationCallbackDelegate(OnWlanNotification);

                Wlan.WlanNotificationSource source;
                Wlan.ThrowIfError(Wlan.WlanRegisterNotification(_clientHandle, Wlan.WlanNotificationSource.All, false, WlanNotificationCallback, IntPtr.Zero, IntPtr.Zero, out source));
            }
            catch (Win32Exception ex)
            {
                Wlan.WlanCloseHandle(_clientHandle, IntPtr.Zero);
                ItsLogger.Warn(ex.Message);
                throw;
            }
        }
開發者ID:parsley72,項目名稱:ManagedWifi,代碼行數:19,代碼來源:WlanClient.cs

示例6: GetOutcome

        private static GlobalSingleInstanceResponseOutcome? GetOutcome(ICollection<RemoteClusterActivationResponse> responses, GrainId grainId, Logger logger, bool hasPendingResponses)
        {
            if (!hasPendingResponses && responses.All(res => res.ResponseStatus == ActivationResponseStatus.Pass))
            {
                // All passed, or no other clusters exist
                return GlobalSingleInstanceResponseOutcome.Succeed;
            }

            var ownerResponses = responses
                .Where(res => res.ResponseStatus == ActivationResponseStatus.Failed && res.Owned == true).ToList();

            if (ownerResponses.Count > 0)
            {
                if (ownerResponses.Count > 1)
                    logger.Warn((int)ErrorCode.GlobalSingleInstance_MultipleOwners, "GSIP:Req {0} Unexpected error occured. Multiple Owner Replies.", grainId);

                return new GlobalSingleInstanceResponseOutcome(OutcomeState.RemoteOwner, ownerResponses[0].ExistingActivationAddress, ownerResponses[0].ClusterId);
            }

            // are all responses here or have failed?
            if (!hasPendingResponses)
            {
                // determine best candidate
                var candidates = responses
                    .Where(res => res.ResponseStatus == ActivationResponseStatus.Failed && res.ExistingActivationAddress.Address != null)
                    .ToList();

                AddressAndTag remoteOwner = new AddressAndTag();
                string remoteOwnerCluster = null;
                foreach (var res in candidates)
                {
                    if (remoteOwner.Address == null ||
                        MultiClusterUtils.ActivationPrecedenceFunc(grainId, res.ClusterId, remoteOwnerCluster))
                    {
                        remoteOwner = res.ExistingActivationAddress;
                        remoteOwnerCluster = res.ClusterId;
                    }
                }

                var outcome = remoteOwner.Address != null ? OutcomeState.RemoteOwnerLikely : OutcomeState.Inconclusive;
                return new GlobalSingleInstanceResponseOutcome(outcome, remoteOwner, remoteOwnerCluster);
            }

            return null;
        }
開發者ID:osjimenez,項目名稱:orleans,代碼行數:45,代碼來源:GlobalSingleInstanceResponseTracker.cs

示例7: ListAllUsers

 /// <summary>
 /// <see cref="INoteManagerService.ListAllUsers"/>
 /// </summary>
 /// <param name="id"></param>
 public UserDTO[] ListAllUsers()
 {
     Logger logger = new Logger(this.GetType());
     logger.Debug("debug");
     logger.Error("error");
     logger.Info("info");
     logger.Warn("warn");
     using (var nme = new NoteManagerEntities())
     {
         var allUsers = from u in nme.User select u;
         List<UserDTO> res = new List<UserDTO>();
         foreach (var u in allUsers)
         {
             res.Add(new UserDTO(u));
         }
         return res.ToArray();
     }
 }
開發者ID:CNicolas,項目名稱:NoteManager,代碼行數:22,代碼來源:NoteManagerService.svc.cs


注:本文中的System.Logger.Warn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。