当前位置: 首页>>代码示例>>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;未经允许,请勿转载。