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


C# ILogger.Fatal方法代码示例

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


在下文中一共展示了ILogger.Fatal方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

        public void Start()
        {
            logger = LoggerFactory.GetLogger("SimpleHttpServer.Server");

            logger.Info("Server starting on port {0}", port);

            if (listener != null)
            {
                logger.Fatal("Server already started");
                throw new InvalidOperationException("Already started");
            }

            listener = new HttpListener();
            listener.Prefixes.Add(string.Format("http://*:{0}/", port));

            try
            {
                listener.Start();
            }
            catch(Exception ex)
            {
                logger.Fatal("Error starting server", ex);
                throw;
            }

            logger.Info("Server started");

            logger.Debug("Waiting for first request");
            listener.BeginGetContext(ProcessRequest, null);
        }
开发者ID:Leafney,项目名称:SimpleHttpServer,代码行数:30,代码来源:Server.cs

示例2: OnStartup

 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     Logger = LogManager.GetCurrentClassLogger();
     try {
         // Exception handlers
         DispatcherUnhandledException += (m, n) => {
             Exception exception = n.Exception;
             Exception innerException = GetInnerException(exception);
             Logger.Error(exception, "[OnStartup] An unhandled dispatcher exception occurred.");
             HandleException(innerException);
             n.Handled = true;
             Current.Shutdown();
         };
         AppDomain.CurrentDomain.UnhandledException += (m, n) => {
             Exception exception = n.ExceptionObject as Exception;
             if (exception == null) {
                 Logger.Fatal("[OnStartup] Unknow error killed application");
             } else {
                 Logger.Fatal(exception, "[OnStartup] An unhandled exception occurred and the application is terminating");
             }
             HandleException(exception);
         };
         // Initialize dispatcher helper so we can access UI thread in view model
         DispatcherHelper.Initialize();
         // Bootstrapping
         DiBootstrapperFrontend.Initialize(IoC.Container);
         Logger.Info("[OnStartup] Application successfully started");
     } catch (Exception exception) {
         Logger.Fatal(exception, "[OnStartup] Error during starting Application");
         HandleException(exception);
         Current.Shutdown();
     }
 }
开发者ID:feitzi,项目名称:Loginator,代码行数:34,代码来源:App.xaml.cs

示例3: LogWithLogger

 private static void LogWithLogger(LogItem logItem, ILogger logger)
 {
     switch (logItem.LogLevel)
     {
         case LogLevel.Trace:
             logger.Trace(() => logItem.Message, logItem.Exception);
             break;
         case LogLevel.Info:
             logger.Info(() => logItem.Message, logItem.Exception);
             break;
         case LogLevel.Warn:
             logger.Warn(() => logItem.Message, logItem.Exception);
             break;
         case LogLevel.Error:
             logger.Error(() => logItem.Message, logItem.Exception);
             break;
         case LogLevel.Fatal:
             logger.Fatal(() => logItem.Message, logItem.Exception);
             break;
     }
 }
开发者ID:encel,项目名称:Encel,代码行数:21,代码来源:CompositeLogger.cs

示例4: CreateLogItems

 public static void CreateLogItems(ILogger logger)
 {
     foreach (var pocoLogItem in Session.List<PocoLogItem>(100).Get())
     {
         switch (pocoLogItem.LogLevel)
         {
             case LogLevel.Debug:
                 logger.Debug(pocoLogItem.Message, pocoLogItem.Details);
                 break;
             case LogLevel.Info:
                 logger.Info(pocoLogItem.Message, pocoLogItem.Details);
                 break;
             case LogLevel.Warning:
                 logger.Warn(pocoLogItem.Message, pocoLogItem.Details);
                 break;
             case LogLevel.Error:
                 logger.Error(pocoLogItem.Message, pocoLogItem.Details);
                 break;
             case LogLevel.Fatal:
                 logger.Fatal(pocoLogItem.Message, new Exception(pocoLogItem.Details));
                 break;
         }
     }
 }
开发者ID:robinvanderknaap,项目名称:SkaeleArchitecture,代码行数:24,代码来源:PocoGenerator.cs

示例5: DefaultContainer

        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultContainer"/> class.
        /// </summary>
        public DefaultContainer()
            : base()
        {
            // 初始化日志系统的相关组件
            try {
                if (loggerFactory == null) throw new Exception("日志对象没有被初始化");
                IConfigurationInterpreter interpreter = new XmlInterpreter();
                interpreter.ProcessResource(interpreter.Source, Kernel.ConfigurationStore);
                this.Kernel.AddComponentInstance("logger", typeof(ILoggerFactory), loggerFactory);
                logger = loggerFactory.CreateLogger<DefaultContainer>("Framework");
            }
            catch (Exception ex) {
                System.Diagnostics.EventLog.WriteEntry("Framework", "日志启动错误:" + ex.Message, System.Diagnostics.EventLogEntryType.Error);
                throw;
            }

            // 加载服务器端的服务
            try {
                string filename = FileUtility.ConvertToFullPath(@"Uniframework.config");
                logger.Info("开始加载注册表服务");
                this.Kernel.AddComponentInstance("configService", typeof(IConfigurationService), new XMLConfigurationService(filename));

                logger.Info("开始加载嵌入式对象数据库服务");
                AddComponent("ObjectDatabaseService", typeof(IDb4oDatabaseService), typeof(Db4oDatabaseService));

                logger.Info("开始加载事件分发服务");
                AddFacility("eventautowiring", new EventAutoWiringFacility());

                logger.Info("开始加载会话管理服务");
                AddComponent("SessionService", typeof(ISessionService), typeof(SessionService));

                logger.Info("开始加载系统管理服务");
                AddFacility("System.Facility", new SystemFacility());

                logger.Info("开始加载客户端初始化服务");
                AddComponent("InitializeService", typeof(IInitializeService), typeof(InitializeService));

                logger.Info("开始加载远程调用服务");
                AddComponent("DefaultServiceCaller", typeof(IServiceCaller), typeof(DefaultServiceCaller));

                CheckBuiltInService(); // 对远程服务及远程方法进行注入处理

                AbstractExtend[] loadedExtends = LoadFrameworkExtends();

                string[] customServices = LoadFrameworkComponents();

                object[] components = ActivatingComponents();

                WiringEvent();

                foreach (AbstractExtend extend in loadedExtends) {
                    extend.LoadFinished(components);
                }

                logger.Info("开始加载应用服务器网关");
                AddComponent("ServiceGateway", typeof(ServiceGateway));

                systemReady = true;
                logger.Info("应用服务器启动完成");
            }
            catch (Exception ex) {
                logger.Fatal("注册组件时发生错误", ex);
            }
        }
开发者ID:wuyingyou,项目名称:uniframework,代码行数:67,代码来源:DefaultContainer.cs

示例6: Main

        private static void Main(string[] args)
        {
            _logger = LogFactory.GetLogger(typeof (Program));

            IDatabaseInitializer<CashRegisterContext> seed;

            // Empty
            // seed = new EmptyInitializer();

            // Kalle Seed
            //seed = new CashProductInitializer();

            // Lærke Seed
            seed = new FullProductInitializer();

            using (var contex = new CashRegisterContext(seed))
            {
                Console.WriteLine("FLAF");
                contex.Database.Initialize(true);
                contex.SaveChanges();
            }

            IDalFacade dalFacade = new DalFacade();
            IProductDao pd = new ProductDao(dalFacade);
            IProductController pc = new ProductController(pd);

            SalesOrder o;

            using (var uow = dalFacade.UnitOfWork)
            {
                var d = new Discount
                {
                    Description = "Discount",
                    Percent = 0,
                };
                uow.DiscountRepository.Insert(d);
                uow.Save();

                o = new SalesOrder
                {
                    Date = DateTime.Now,
                    Status = OrderStatus.Created,
                };
                uow.SalesOrderRepository.Insert(o);

            }
            using (var uow = dalFacade.UnitOfWork)
            {

                var t = new Transaction
                {
                    Date = DateTime.Now,
                    Description = "Flaf",
                    PaymentType = PaymentType.Cash,
                    Price = 20,
                    SalesOrder = o,
                    Status = TransactionStatus.Created
                };
                uow.TransactionRepository.Insert(t);
                uow.Save();
            }

                Console.WriteLine("ProductTabs");
            foreach (var productTab in pc.ProductTabs)
            {
                Console.WriteLine(productTab.Priority + ": " + productTab.Name);
                foreach (var productType in productTab.ProductTypes)
                {
                    Console.WriteLine("\t" + productType.Name);
                    foreach (var productGroup in productType.ProductGroups)
                    {
                        Console.WriteLine("\t\t" + productGroup.Name);
                        foreach (var product in productGroup.Products)
                        {
                            Console.WriteLine("\t\t\t" + product.Name);
                        }
                    }
                }
            }

            _logger.Fatal("Fatal");
            _logger.Err("Error");
            _logger.Warn("Warn");
            _logger.Info("Info");
            _logger.Debug("Debug");
        }
开发者ID:KasperSK,项目名称:TripleA,代码行数:86,代码来源:Program.cs

示例7: CollectorService

        public CollectorService(IEnumerable<string> work_on_this_users_only = null)
        {
            ServiceName = asc_mail_collection_service_name;
            EventLog.Log = "Application";

            // These Flags set whether or not to handle that specific
            // type of event. Set to true if you need it, false otherwise.
            CanHandlePowerEvent = false;
            CanHandleSessionChangeEvent = false;
            CanPauseAndContinue = false;
            CanShutdown = true;
            CanStop = true;
            try
            {
                _log = LoggerFactory.GetLogger(LoggerFactory.LoggerType.Nlog, "CollectorService");

                _log.Info("Connecting to db...");

                _manager = new MailBoxManager(25, _log);

                var auth_error_warning_timeout =
                    ConfigurationManager.AppSettings["mail.AuthErrorSendWarningAlertTimeout"] != null
                        ? TimeSpan.FromSeconds(
                            Convert.ToInt32(ConfigurationManager.AppSettings["mail.AuthErrorSendWarningAlertTimeout"]))
                        : TimeSpan.FromHours(2);

                _manager.AuthErrorWarningTimeout = auth_error_warning_timeout;

                _log.Info("Auth login error warning timeout is {0}.", auth_error_warning_timeout.ToString());

                var auth_error_disable_mailbox_timeout =
                    ConfigurationManager.AppSettings["mail.AuthErrorDisableMailboxTimeout"] != null
                        ? TimeSpan.FromSeconds(
                            Convert.ToInt32(ConfigurationManager.AppSettings["mail.AuthErrorDisableMailboxTimeout"]))
                        : TimeSpan.FromDays(3);

                _log.Info("Auth login error disable mailbox timeout is {0}.", auth_error_disable_mailbox_timeout.ToString());

                _manager.AuthErrorDisableTimeout = auth_error_disable_mailbox_timeout;

                _log.Info("Creating collector service...");

                var handlers_log = LoggerFactory.GetLogger(LoggerFactory.LoggerType.Nlog, "MessageHandlers");
                var queue_settings = MailQueueSettings.FromConfig;
                if (work_on_this_users_only != null)
                    queue_settings.WorkOnUsersOnly = work_on_this_users_only.ToList();
                else
                {
                    var user_to_work_on = ConfigurationManager.AppSettings["mail.OneUserMode"];
                    if (!string.IsNullOrEmpty(user_to_work_on))
                        queue_settings.WorkOnUsersOnly.Add(user_to_work_on);
                }

                _manager.TenantOverdueDays = queue_settings.OverdueDays;

                var handlers = MessageHandlersSettings.FromConfig(handlers_log, "mail");

                var enable_activity_log = ConfigurationManager.AppSettings["mail.EnableActivityLog"] == null || Convert.ToBoolean(ConfigurationManager.AppSettings["mail.EnableActivityLog"]);

                _manager.EnableActivityLog = enable_activity_log;

                _log.Info("Db aggregator activity log is {0}.", enable_activity_log ? "enabled" : "disabled");

                _collector = new Collector(_manager, queue_settings, handlers);

                _log.Info("Service is ready.");

                AggregatorLogger.Instance.Initialize(_manager, GetServiceIp());
                _log.Info("Aggregator logger initialized.");
            }
            catch (Exception ex)
            {
                _log.Fatal("CollectorService error under constuct: {0}", ex.ToString());
            }
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:75,代码来源:CollectorService.cs

示例8: Log

 protected override void Log(ILogger logger, string format, params object[] args)
 {
     logger.Fatal(format, args);
 }
开发者ID:CallWall,项目名称:CallWall.Windows,代码行数:4,代码来源:LogExtensionTests.cs

示例9: AggregatorService


//.........这里部分代码省略.........
                if (workOnThisUsersOnly != null)
                    _queueSettings.WorkOnUsersOnly = workOnThisUsersOnly.ToList();
                else
                {
                    var userToWorkOn = ConfigurationManager.AppSettings["mail.OneUserMode"];
                    if (!string.IsNullOrEmpty(userToWorkOn))
                        _queueSettings.WorkOnUsersOnly.Add(userToWorkOn);
                }

                var authErrorWarningTimeout =
                    ConfigurationManager.AppSettings["mail.auth-error-warning-in-minutes"] != null
                        ? TimeSpan.FromMinutes(
                            Convert.ToInt32(ConfigurationManager.AppSettings["mail.auth-error-warning-in-minutes"]))
                        : TimeSpan.FromHours(1);

                _log.Info("Auth login error warning timeout is {0}.", authErrorWarningTimeout.ToString());

                var authErrorDisableMailboxTimeout =
                    ConfigurationManager.AppSettings["mail.auth-error-disable-mailbox-in-minutes"] != null
                        ? TimeSpan.FromMinutes(
                            Convert.ToInt32(ConfigurationManager.AppSettings["mail.auth-error-disable-mailbox-in-minutes"]))
                        : TimeSpan.FromDays(3);

                _log.Info("Auth login error disable mailbox timeout is {0}.", authErrorDisableMailboxTimeout.ToString());

                _log.Info("MailWorkerQueue: ConcurrentThreadCount = {0} and CheckInterval = {1} CheckPOP3_UIDL_Chunck = {2}",
                _queueSettings.ConcurrentThreadCount, _queueSettings.CheckInterval, _queueSettings.CheckPop3UidlChunk);

                var configBuilder = new TasksConfig.Builder();

                if (_queueSettings.WorkOnUsersOnly != null && _queueSettings.WorkOnUsersOnly.Any())
                {
                    var i = 0;
                    var users = string.Empty;
                    _queueSettings.WorkOnUsersOnly.ForEach(user => users += string.Format("\r\n\t\t\t\t{0}. \"{1}\"", ++i, user));

                    _log.Info("Aggregator will get tasks for this users only:" + users);
                }

                var queueLifetime = ConfigurationManager.AppSettings["mail.queue-lifetime-seconds"] != null
                        ? TimeSpan.FromSeconds(
                            Convert.ToInt32(ConfigurationManager.AppSettings["mail.queue-lifetime-seconds"]))
                        : TimeSpan.FromSeconds(30);

                var showActiveUpLogs = ConfigurationManager.AppSettings["mail.show-activeup-logs"] != null &&
                                       Convert.ToBoolean(
                                           ConfigurationManager.AppSettings["mail.show-activeup-logs"]);

                _tasksConfig = configBuilder.SetUsersToWorkOn(_queueSettings.WorkOnUsersOnly)
                                            .SetOnlyTeamlabTasks(_queueSettings.OnlyTeamlabTasks)
                                            .SetActiveInterval(_queueSettings.ActivityTimeout)
                                            .SetChunkOfPop3CheckUidLinDb(_queueSettings.CheckPop3UidlChunk)
                                            .SetEnableSignalr(_queueSettings.EnableSignalr)
                                            .SetMaxMessagesPerSession(_queueSettings.MaxMessagesPerSession)
                                            .SetMaxTasksAtOnce(_queueSettings.ConcurrentThreadCount)
                                            .SetQueueLifetime(queueLifetime)
                                            .SetTenantCachingPeriod(_queueSettings.TenantCachingPeriod)
                                            .SetShowActiveUpLogs(showActiveUpLogs)
                                            .SetInactiveMailboxesRatio(_queueSettings.InactiveMailboxesRatio)
                                            .SetAuthErrorWarningTimeout(authErrorWarningTimeout)
                                            .SetAuthErrorDisableMailboxTimeout(authErrorDisableMailboxTimeout)
                                            .Build();

                _tsInterval = _queueSettings.CheckInterval;

                _manager = new MailBoxManager(_log)
                {
                    AuthErrorWarningTimeout = _tasksConfig.AuthErrorWarningTimeout,
                    AuthErrorDisableTimeout = _tasksConfig.AuthErrorDisableMailboxTimeout
                };

                _queueManager = new QueueManager(_manager, _tasksConfig, _log);

                _resetEvent = new ManualResetEvent(false);

                _cancelTokenSource = new CancellationTokenSource();

                _lcts = new LimitedConcurrencyLevelTaskScheduler(_tasksConfig.MaxTasksAtOnce);

                _taskFactory = new TaskFactory(_lcts);

                _tsTaskStateCheckInterval = ConfigurationManager.AppSettings["mail.task-check-state-seconds"] != null
                        ? TimeSpan.FromSeconds(
                            Convert.ToInt32(ConfigurationManager.AppSettings["mail.task-check-state-seconds"]))
                        : TimeSpan.FromSeconds(30);

                if (ConfigurationManager.AppSettings["mail.default-api-scheme"] != null)
                {
                    var defaultApiScheme = ConfigurationManager.AppSettings["mail.default-api-scheme"];

                    ApiHelper.SetupScheme(defaultApiScheme);
                }

                _log.Info("Service is ready.");
            }
            catch (Exception ex)
            {
                _log.Fatal("CollectorService error under construct: {0}", ex.ToString());
            }
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:101,代码来源:AggregatorService.cs

示例10: ProcessFile

        private static void ProcessFile(string file, Func<string, bool> assemblyVersionCondition, IList<Assembly> assemblyList, ILogger logger)
        {
            try
            {
                logger.Info(string.Format(CultureInfo.InvariantCulture, "GACAssemblyLocator filename match! Loading assembly {0}.", file));
                Assembly a = Assembly.LoadFile(file);

                if (assemblyVersionCondition != null)
                {
                    if (assemblyVersionCondition(a.FullName))
                    {
                        assemblyList.Add(a);
                    }
                }
                else
                {
                    // If no condition is specified, accept DLLs from all versions
                    assemblyList.Add(a);
                }
            }
            catch (Exception error)
            {
                logger.Fatal(string.Format(CultureInfo.InvariantCulture, "GACAssemblyLocator failed to load assembly (file {0}). Error: {1}", file, error.ToString()));
            }
        }
开发者ID:andresglx,项目名称:Dynamite,代码行数:25,代码来源:GacAssemblyLocator.cs

示例11: LogAllLevelMessages

 //use for testing purposes
 public static void LogAllLevelMessages(ILogger logger)
 {
     logger.Debug("Hey, are you a programmer? Logger.Name = " + logger.Name);
     logger.Info("Here's something interesting.");
     logger.Warn("Uh-oh, that's disturbing.");
     logger.Error("That was unexpected.");
     logger.Fatal("The roof is on fire!");
 }
开发者ID:dzstoever,项目名称:ZenFacades,代码行数:9,代码来源:Log4netConfigurator.cs


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