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


C# Logger.ErrorException方法代碼示例

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


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

示例1: MainClass

        public MainClass(string [] args)
        {
            Ticker.Tick();

            // required for the MS .NET runtime that doesn't initialize glib automatically
            if (!GLib.Thread.Supported)
                GLib.Thread.Init();

            // Connect to dbus
            DBusInstance DBusInstance = ServiceManager.Get <DBusInstance> ();
            DBusInstance.Initialise ();

            if (DBusInstance.AlreadyRunning)
            {
                Console.WriteLine("Already running");
                DBusInstance.CommandParser.ParseCommands (args);
                return;
            }

            DBusInstance.CommandParser.RunCommand += HandleCommand;

            Ticker.Tick();
            CheckDataFolders();
            Ticker.Tock ("Checking folders");

            foreach (string arg in args)
                HandleCommand (arg);

            Ticker.Tick ();
            if (DebugEnabled) {
                BuildNlogConfig();
            }
            logger = DebugEnabled ? NLog.LogManager.GetCurrentClassLogger () : new EmptyLogger ();
            Ticker.Tock("NLog");

            logger.Info("Starting Monsoon");

            Ticker.Tick ();
            SetProcessName("monsoon");
            Ticker.Tock("Setting process name");

            string localeDir = Path.Combine(Defines.ApplicationDirectory, "locale");
            if (!Directory.Exists(localeDir)) {
                localeDir = Path.Combine(Defines.InstallPrefix, "share");
                localeDir = Path.Combine(localeDir, "locale");
            }

            Ticker.Tick ();
            Mono.Unix.Catalog.Init("monsoon", localeDir);
            logger.Debug("Using locale data from: {0}", localeDir);

            Application.Init("monsoon", ref args);
            Ticker.Tock("Locale");

            try {
                SettingsManager.Restore <EngineSettings> (SettingsManager.EngineSettings);
                SettingsManager.Restore <PreferencesSettings> (SettingsManager.Preferences);
                SettingsManager.Restore <TorrentSettings> (SettingsManager.DefaultTorrentSettings);
            }
            catch (Exception ex) {
                logger.Error("Couldn't restore old settings: {0}", ex.Message);
            }

            try
            {
                Ticker.Tick();
                mainWindow = new MainWindow ();
                Ticker.Tock ("Instantiating window");

            }
            catch(Exception e)
            {
                logger.ErrorException(e.Message, e);
                Environment.Exit (0);
            }

            LoadAddins ();

            GLib.ExceptionManager.UnhandledException += new GLib.UnhandledExceptionHandler(OnUnhandledException);

            Ticker.Tock ("Total time:");
            Application.Run();

            try {
                SettingsManager.Store <EngineSettings> (SettingsManager.EngineSettings);
                SettingsManager.Store <PreferencesSettings> (SettingsManager.Preferences);
                SettingsManager.Store <TorrentSettings> (SettingsManager.DefaultTorrentSettings);
            }
            catch (Exception ex) {
                logger.Error("Could save engine settings: {0}", ex.Message);
            }
            ServiceManager.Get <ListenPortController> ().Stop ();
            mainWindow.Destroy ();
        }
開發者ID:ArsenShnurkov,項目名稱:monsoon,代碼行數:94,代碼來源:Main.cs


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