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


C# Logger.Error方法代碼示例

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


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

示例1: MainForm

        /// <summary>
        /// Keep track if we have sent an error popup notification, if so use this value to supress future popups, under the assumption that the first one is the most important and probably the originator of the future popups.
        /// </summary>
        public MainForm()
        {
            // Machine number
            m_strMachineNumber = System.Configuration.ConfigurationManager.AppSettings["machineNumber"];

            //Setup the Logging system
            m_logAndErr = new LogAndErrorsUtils(AutoDialIcon, ToolTipIcon.Error);
            m_imgManUtils = new ImageManipulationUtils(m_logAndErr);
            m_logger = m_logAndErr.getLogger();

            // Give the admins a chance to change the path of tessdata
            string TESSERACT_DATA_PATH = System.Configuration.ConfigurationManager.AppSettings["tessdataPath"];
            if (TESSERACT_DATA_PATH == null)
            {

                TESSERACT_DATA_PATH = @"C:\\Autodial\\Dialing\\tessdata";
                m_logger.Error("No Config Tesseract path. Setting to: {0}", TESSERACT_DATA_PATH);
            }

            // Initilialise event for timer tick
            m_timer.Tick += new EventHandler(timerTick);

            //Initialise the Form
            InitializeComponent();

            m_logger.Info("###################################################################");
            m_logger.Info("Starting Program");

            // Checking for tesseract data path
            if (!System.IO.Directory.Exists(TESSERACT_DATA_PATH))
            {
                string strError = "Couldn't find tesseract in " + TESSERACT_DATA_PATH;
                m_logger.Error(strError);
                m_logger.Info(MailUtils.MailUtils.sendit("[email protected]", m_strMachineNumber, strError, m_strDailyLogFilename));
            }

            // Set the Talk Log Monitor Util
            Regex regEx = new Regex("answered|disconnected");
            string strTalkLogPath = System.Configuration.ConfigurationManager.AppSettings["talkLogPath"];
            m_logger.Info("Talk Log path: " + strTalkLogPath);
            string strLogFilePath = TalkLogMonitorUtil.getTalkLogFileNameFromTalkLogDirectory(DateTime.Today, strTalkLogPath);
            m_logger.Info("Talk File Log path: " + strLogFilePath);
            m_talkLogMonitor = new TalkLogMonitorUtil(strLogFilePath, stopAlertTimer, regEx);

            string strYear = DateTime.Today.Year.ToString();
            string strMonth = (DateTime.Today.Month < 10) ? ("0" + DateTime.Today.Month.ToString()) : DateTime.Today.Month.ToString();
            string strDay = (DateTime.Today.Day < 10) ? ("0" + DateTime.Today.Day.ToString()) : DateTime.Today.Day.ToString();

            m_strDailyLogFilename = @"C:\AutoDial\Log\AutoDial_" +
                                    strYear + "-" +
                                    strMonth + "-" +
                                    strDay + "_trace.log"; // AutoDial_2015-10-28_trace.log

            registerHotkey();
            customHide();
        }
開發者ID:ignazio-castrogiovanni,項目名稱:OCR_AD,代碼行數:59,代碼來源:Form1.cs

示例2: Compile

        public static ABIExitCode Compile(ABIFileSystemOptions options, LogFactory factory)
        {
            #region Argument exceptions

            if (options == null)
                throw new ArgumentNullException("options");

            if (factory == null)
                throw new ArgumentNullException("factory");

            #endregion

            _logger = factory.GetCurrentClassLogger();
            _logger.Debug(options);
            try
            {
                if (!Validate(options))
                    return ABIExitCode.ErrorDuringValidation;

                var engine = new CompilerEngine(options, factory);

                var result = engine.Compile();
                Debug.Assert(result != ABIExitCode.ErrorExitCodeUnassigned);
                return result;
            }
            catch (Exception ex) // avoid external unhandled exceptions
            {
                _logger.Error(ex);
            }

            return ABIExitCode.ErrorUnhandledException;
        }
開發者ID:SolidQIT,項目名稱:ABI-Compiler,代碼行數:32,代碼來源:ABIFileSystemCompiler.cs

示例3: Execute

        /// <summary>
        /// Called by the <see cref="T:Quartz.IScheduler"/> when a <see cref="T:Quartz.ITrigger"/>
        ///             fires that is associated with the <see cref="T:Quartz.IJob"/>.
        /// </summary>
        /// <remarks>
        /// The implementation may wish to set a  result object on the
        ///             JobExecutionContext before this method exits.  The result itself
        ///             is meaningless to Quartz, but may be informative to
        ///             <see cref="T:Quartz.IJobListener"/>s or
        ///             <see cref="T:Quartz.ITriggerListener"/>s that are watching the job's
        ///             execution.
        /// </remarks>
        /// <param name="context">The execution context.</param>
        public void Execute(IJobExecutionContext context)
        {
            _logger = LogManager.GetCurrentClassLogger();

            JobDataMap dataMap = context.JobDetail.JobDataMap;
            EconomicReleaseUpdateJobSettings settings;
            try
            {
                settings = JsonConvert.DeserializeObject<EconomicReleaseUpdateJobSettings>((string)dataMap["settings"]);
            }
            catch (Exception e)
            {
                _logger.Error(e, "Failed to deserialize data update job settings");
                return;
            }

            _logger.Info($"Data Update job {settings.Name} triggered.");

            _broker.Error += _broker_Error;

            var startDate = DateTime.Now.AddBusinessDays(-settings.BusinessDaysBack);
            var endDate = DateTime.Now.AddBusinessDays(settings.BusinessDaysAhead);
            var req = new EconomicReleaseRequest(startDate, endDate, dataLocation: DataLocation.ExternalOnly, dataSource: settings.DataSource);
            var releases = _broker.RequestEconomicReleases(req).Result; //no async support in Quartz, and no need for it anyway, this runs on its own thread
            _logger.Trace($"Economic release update job downloaded {releases.Count} items");

            JobComplete();
        }
開發者ID:leo90skk,項目名稱:qdms,代碼行數:41,代碼來源:EconomicReleaseUpdateJob.cs

示例4: Main

        static void Main()
        {
            _log = LogManager.GetCurrentClassLogger();
            _log.Warn("Service is about to start");
#if DEBUG
            LogManager.GlobalThreshold = LogLevel.Trace;
#endif
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;

            try
            {
                var container = new Container(new SensuClientRegistry());
                var sensuClient = container.GetInstance<ISensuClient>() as ServiceBase;
                
                ServiceBase[] servicesToRun;
                servicesToRun = new ServiceBase[] 
                {
                    sensuClient
                 };

                if (Environment.UserInteractive)
                {
                    RunInteractive(servicesToRun);
                }
                else
                {
                    ServiceBase.Run(servicesToRun);
                }
            }
            catch (Exception exception)
            {
                _log.Error(exception, "Error in startup sensu-client.");
            }
            
        }
開發者ID:dogtbh,項目名稱:sensu-client,代碼行數:35,代碼來源:Program.cs

示例5: ProcessResults

 public static void ProcessResults(JSONDiff jd, Logger l)
 {
     if (jd.Messages.Any())
     {
         l.Info("--Issues--");
         jd.Messages.ForEach(s2 =>
         {
             var mess = s2.Message?.Trim();
             var exp = s2.Exception?.Trim();
             var m = $"{s2.ProblemType} | {mess} | {exp}";
             m = m.Replace("\r\n", "");
             switch (s2.WarnLevel)
             {
                 case JSONWarnLevel.Warn:
                     l.Warn(m);
                     break;
                 case JSONWarnLevel.Error:
                     l.Error(m);
                     break;
                 case JSONWarnLevel.Fatal:
                     l.Fatal(m);
                     break;
                 default:
                     throw new ArgumentOutOfRangeException();
             }
         });
         l.Info("-----------");
     }
     else
     {
         l.Info("--Success--");
         l.Info("-----------");
     }
 }
開發者ID:andreigec,項目名稱:Happy-Diff,代碼行數:34,代碼來源:Controller.cs

示例6: QueueProcessor

        public QueueProcessor(Logger log, IDataStore dataStore, IHubContext<IMatchmakingClient> hub, ITracker tracker, IMatchEvaluator matchBuilder, CircularBuffer<TimeSpan> timeToMatch)
        {
            _log = log;
            _dataStore = dataStore;
            _hub = hub;
            _tracker = tracker;
            _matchBuilder = matchBuilder;
            _timeToMatch = timeToMatch;

            _queueSleepMin = Int32.Parse( CloudConfigurationManager.GetSetting("QueueSleepMin") );
            _queueSleepMax = Int32.Parse( CloudConfigurationManager.GetSetting("QueueSleepMax") );
            _queueSleepLength = Int32.Parse( CloudConfigurationManager.GetSetting("QueueSleepLength") );

            Task.Run( async () =>
            {
                _log.Info("Running QueueProcessor...");

                while( true )
                {
                    var sleepTime = _queueSleepMax;

                    try
                    {
                        await processQueue();
                        sleepTime = _queueSleepMax - (_dataStore.DocumentDbPopulation * (_queueSleepMax/_queueSleepLength));
                    }
                    catch(Exception ex)
                    {
                        _log.Error(ex);
                    }

                    Thread.Sleep(sleepTime < _queueSleepMin ? _queueSleepMin : sleepTime);
                }
            });
        }
開發者ID:spencerhakim,項目名稱:firetea.ms,代碼行數:35,代碼來源:QueueProcessor.cs

示例7: GetADDirectoryEntry

        public DirectoryEntry GetADDirectoryEntry(string FQDomainName, string LDAPPath, Logger Logger)
        {
            Logger.Debug(string.Format(@"Getting Directory Entry for LDAP Path {0}", LDAPPath));

            //DirectoryEntry LDAPConnection = new DirectoryEntry(FQDomainName);
            DirectoryEntry LDAPConnection = new DirectoryEntry("LDAP://"+FQDomainName);

            LDAPConnection.Path = "LDAP://"+LDAPPath;
            LDAPConnection.AuthenticationType = AuthenticationTypes.Secure;

               try
               {
               //Try fetch to Native ADSI Object  - if this passes Then we know that we
               //are authenticated. If an exception is thrown then we know we are using an Invalid Account.

               object DirEntryNativeObject = LDAPConnection.NativeObject;

               }
               catch (Exception ex)
               {
               Logger.Error(String.Format("Error authenticating to Active Directory with current running user. {0} {1}.",
                   ex.Message, ex.InnerException != null ? ex.InnerException.Message : ""));

               throw new Exception(String.Format("Error authenticating to Active Directory with current running user. {0} {1}.",
                   ex.Message, ex.InnerException != null ? ex.InnerException.Message : "" ));
               }

               return LDAPConnection;
        }
開發者ID:spSlaine,項目名稱:ADCST,代碼行數:29,代碼來源:OnPremADHelper.cs

示例8: Main

 static void Main(string[] args)
 {
     try
     {
         log = LogManager.GetCurrentClassLogger();
         BookListService bls = new BookListService();
         log.Debug("Старт записи в двоичный файл");
             WriteDefaultValues(fileName);
         log.Debug("Окончание записи в двоичный файл");
         log.Debug("Старт чтения данных из двоичног файла");
         bls = ReadDefaultValues(fileName);
         log.Debug("Окончание чтения данных из двоичног файла");
         Book[] find = bls.FindByTag("1999", EnumTag.Year); //Поиск
         foreach (Book b in find)
         Console.WriteLine(b);
         Console.WriteLine("-------------------------");
         Book[] sort = bls.SortBooksByTag(EnumTag.Page);//Сортировка
         foreach (Book b in sort)
             Console.WriteLine(b);
         //log.Warn("Попытка добавить уже существующую книгу");
         //bls.AddBook(sort[0]); 
         bls.RemoveBook(sort[0]);//Удаление книги
         log.Warn("Попытка удаления книги отсутствующей в каталоге");
         bls.RemoveBook(sort[0]);
     }
     catch (Exception e)
     {
         log.Error(e.Message);
     }
     
 }
開發者ID:eduard-posmetuhov,項目名稱:ASP.NET.Posmetuhov.Day5,代碼行數:31,代碼來源:Program.cs

示例9: Application_Error

        protected void Application_Error(object sender, EventArgs e)
        {
            Exception lastError = this.Server.GetLastError();
            Exception originalError = lastError.InnerException ?? lastError;

            logger = LogManager.GetCurrentClassLogger();
            logger.Error(originalError.Message, originalError);
        }
開發者ID:skalinkin,項目名稱:WPAgent,代碼行數:8,代碼來源:Global.asax.cs

示例10: convertStringToInt

        public int convertStringToInt(string name, string source, Logger logger)
        {
            if (source == null)
            {
                logger.Error("Error: " + name + " Is Null, Check config file.");
                m_logAndErr.errorPopup("Config error", "Error: " + name + " is null, check config file.");

                return 0;
            }

            return Convert.ToInt32(source);
        }
開發者ID:ignazio-castrogiovanni,項目名稱:OCR_AD,代碼行數:12,代碼來源:GeneralUtils.cs

示例11: GetAllPriorityType

 public static IList<PriorityType> GetAllPriorityType(this AmarisEntities db, Logger log, bool isDeleted)
 {
     try
     {
         return db.PriorityTypes.Where(x => x.IsDeleted == isDeleted).ToList();
     }
     catch (Exception ex)
     {
         log.Error(ex);
         return new List<PriorityType>();
     }
 }
開發者ID:dangokc,項目名稱:CodeSnippets,代碼行數:12,代碼來源:PriorityTypeRepository.cs

示例12: Fill

 public void Fill(SPClientContext clientContext, Logger logger)
 {
     if (logger != null)
     {
         _viewModel.FailEvent += (senser, e) => Dispatcher.Invoke(() => logger.Error(e.Exception.Message));
     }
     //if (IsMulti)
     //{
     _viewModel.Add(clientContext);
     DataContext = _viewModel;
     //}
 }
開發者ID:rlocus,項目名稱:SPAccess,代碼行數:12,代碼來源:SPClientTreeView.xaml.cs

示例13: GetAllDeadlineType

 public IList<DeadlineType> GetAllDeadlineType(AmarisEntities db, Logger log, bool isDeleted)
 {
     try
     {
         return db.DeadlineTypes.Where(x => x.IsDeleted == isDeleted).ToList();
     }
     catch (Exception ex)
     {
         log.Error(ex);
         return new List<DeadlineType>();
     }
 }
開發者ID:dangokc,項目名稱:CodeSnippets,代碼行數:12,代碼來源:DeadlineTypeRepository.cs

示例14: GetAllPriority

 public static IEnumerable<Priority> GetAllPriority(this AmarisEntities db, Logger log)
 {
     try
     {
         return db.Priorities;
     }
     catch (Exception ex)
     {
         log.Error(ex);
         return null;
     }
 }
開發者ID:dangokc,項目名稱:CodeSnippets,代碼行數:12,代碼來源:CountryPriorityRepository.cs

示例15: LogFailure

 static public void LogFailure(this ElasticsearchResponse<string> response, Logger logger, string message = "")
 {
     if (string.IsNullOrEmpty(message))
         message = "request failed";
     
     logger.Error("{0}: {1}, {2}, {3}, {4}, {5}, '{6}'; request={7}", 
         message, 
         response.HttpStatusCode,
         response.RequestMethod,
         response.RequestUrl,
         response.ServerError,
         response.OriginalException,
         response.Response,
         System.Text.Encoding.Default.GetString(response.Request));
 }
開發者ID:kevintavog,項目名稱:FIndAPhoto-2.net,代碼行數:15,代碼來源:ResponseExtensions.cs


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