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


C# Logger.Info方法代碼示例

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


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

示例1: CollectorService

        public CollectorService()
        {
            this.ServiceName = AscMailCollectionServiceName;
            this.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.
            this.CanHandlePowerEvent = false;
            this.CanHandleSessionChangeEvent = false;
            this.CanPauseAndContinue = false;
            this.CanShutdown = true;
            this.CanStop = true;
            try
            {
                _log = LogManager.GetLogger("CollectorService");
                _log.Info("Connecting to db...");
                _manger = new MailBoxManager(ConfigurationManager.ConnectionStrings["mail"], 25);
                _log.Info("Creating collector service...");
                _collector = new Collector(_manger, MailQueueSettings.FromConfig);
                _log.Info("Service is ready.");

                AggregatorLogger.Instance.Initialize(_manger, GetServiceIp());
                _log.Info("Aggregator logger initialized.");
            }
            catch (Exception ex)
            {
                _log.Fatal("CollectorService error under constuct: {0}", ex.ToString());
            }
        }
開發者ID:Inzaghi2012,項目名稱:teamlab.v7.5,代碼行數:29,代碼來源:CollectorService.cs

示例2: 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

示例3: Main

        static void Main(string[] args)
        {
            log = LogManager.GetCurrentClassLogger();

            log.Info("Version: {0}", RocksmithToolkitLib.ToolkitVersion.version);
            log.Info("OS: {0}", Environment.OSVersion.ToString());
            log.Info("Command: {0}", Environment.CommandLine.ToString());

            AppDomain.CurrentDomain.UnhandledException += (s, e) =>
            {
                var exception = (Exception)e.ExceptionObject;
                MessageBox.Show(String.Format("Application.ThreadException\n{0}\n{1}\nPlease send us \"_RSToolkit_{2}.log\", you can find it in Toolkit folder.",
                    exception.ToString(), exception.Message.ToString(), DateTime.Now.ToString("yyyy-MM-dd")), "Unhandled Exception catched!");
                log.ErrorException(String.Format("\n{0}\n{1}\nException catched:\n{2}\n", exception.Source, exception.TargetSite, exception.InnerException), exception);
            };

            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // UI thread exceptions handling.
            Application.ThreadException += (s, e) =>
            {
                var exception = (Exception)e.Exception;
                MessageBox.Show(String.Format("Application.ThreadException\n{0}\n{1}\nPlease send us \"_RSToolkit_{2}.log\", you can find it in Toolkit folder.",
                    exception.ToString(),  exception.Message.ToString(), DateTime.Now.ToString("yyyy-MM-dd")), "Thread Exception catched!");
                log.ErrorException(String.Format("\n{0}\n{1}\nException catched:\n{2}\n", exception.Source, exception.TargetSite, exception.InnerException), exception);
            };

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            Application.Run(new MainForm(args));
        }
開發者ID:Jamedjo,項目名稱:rocksmith-custom-song-toolkit,代碼行數:32,代碼來源:Program.cs

示例4: GetJob

        public static Job GetJob(int jobId, Logger defaultLogger)
        {
            Job currentJob;
            using (var repo = new JobRepository())
            {
                defaultLogger.Info("Passed job with ID of {0}", jobId);

                currentJob = repo.GetJobById(jobId);

                if (currentJob == null)
                {
                    defaultLogger.Warn("Job not found");
                    return null;
                }

                defaultLogger.Info("Job found. URL is {0} and branch is {1}", currentJob.Url, currentJob.Branch);

                if (currentJob.State != JobState.Pending)
                {
                    defaultLogger.Warn("Cannot start job. Current state is {0}", currentJob.State);
                    return null;
                }

                repo.UpdateStateForJob(currentJob, JobState.Running);
            }

            return currentJob;
        }
開發者ID:tompoole,項目名稱:DeploymentManager,代碼行數:28,代碼來源:JobHelper.cs

示例5: 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

示例6: Main

        /// <summary>
        /// Point d'entrée.
        /// </summary>
        static void Main(string[] args)
        {
            _logger = LogManager.GetLogger("Program");
            if (!Environment.UserInteractive)
            {
                #region Considère un contexte de service
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new Service.MemcachedService()
                };
                ServiceBase.Run(ServicesToRun);
                #endregion
            }
            else
            {
                #region Considère un contexte utilisateur (interactif)
                _logger.Trace("Mode interactif");
                int exitCode = 0;
                try
                {
                    #region Parse la ligne de commande
                    Options options = new Options();
                    ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(false, true, Console.Error));
                    bool parserSucceed = parser.ParseArguments(args, options);
                    #endregion

                    if (options.Install || options.Uninstall)
                    {
                        if (!parserSucceed)
                            throw new ArgumentException("Ligne de commande invalide.");
                        Service.MemcachedServiceInstaller.Install(options.Uninstall, args);
                        return;
                    }

                    using (var service = new Service.MemcachedService())
                    {
                        service.SetUp(!parserSucceed ? args.Length != 0 ? args : AppSettings.GetMemcachedArguments() : AppSettings.GetMemcachedArguments());
                        _logger.Info("Service démarré. Appuyez sur ECHAP pour mettre fin au service...");

                        while (!NativeMethods.PeekEscapeKey()) { }
                        _logger.Info("[ESC]");
                        service.TearDown();
                    }
                }
                catch (Exception ex)
                {
                    _logger.Fatal(ex.ToString());
                    exitCode = -1;
                }
                Environment.Exit(exitCode);
                #endregion
            }
        }
開發者ID:eric-b,項目名稱:MemcachedService64,代碼行數:57,代碼來源:Program.cs

示例7: SensuClientConfigurationReader

 public SensuClientConfigurationReader(IConfigurationPathResolver configurationPathResolver)
 {
     _configurationPathResolver = configurationPathResolver;
     _log = LogManager.GetCurrentClassLogger();
     _configfile = configurationPathResolver.ConfigFileName();
     _configdir = configurationPathResolver.Configdir();
     _log.Info("Configuration file: {0}", _configfile);
     _log.Info("Configuration directory: {0}",_configdir);
     rwlock = new ReaderWriterLockSlim();
     InitFileSystemWatcher();
     
 }
開發者ID:dogtbh,項目名稱:sensu-client,代碼行數:12,代碼來源:SensuClientConfigurationReader.cs

示例8: createDefaultReporter

        public static SyntheticCountersReporter createDefaultReporter(Logger _log, ICounterSamplingConfiguration counterSamplingConfig)
        {
            string signalFxCategory = "SignalFX";

            try
            {
                System.Diagnostics.CounterCreationDataCollection CounterDatas =
                   new System.Diagnostics.CounterCreationDataCollection();

                createCounterIfNotExist(signalFxCategory, "UsedMemory", "Total used memory", System.Diagnostics.PerformanceCounterType.NumberOfItems64, CounterDatas);

                if (CounterDatas.Count != 0)
                {
                    System.Diagnostics.PerformanceCounterCategory.Create(
                        signalFxCategory, "SignalFx synthetic counters.",
                        System.Diagnostics.PerformanceCounterCategoryType.SingleInstance, CounterDatas);
                }
            }
            catch (Exception e)
            {
                _log.Info(e.ToString());
                return null;
            }

            SyntheticCountersReporter reporter = new SyntheticCountersReporter(counterSamplingConfig);
            reporter._sfxCountersUpdateMethods.Add("UsedMemory", updateUsedMemoryCounter);
            return reporter;
        }
開發者ID:BitBuster,項目名稱:PerfCounterReporter,代碼行數:28,代碼來源:SyntheticCountersReporter.cs

示例9: Index

        // GET: Movies
        public ActionResult Index(string movieGenre, string searchString)
        {
            var GenreLst = new List<string>();

            var GenreQry = from d in db.Movies
                           orderby d.Genre
                           select d.Genre;

            GenreLst.AddRange(GenreQry.Distinct());
            ViewBag.movieGenre = new SelectList(GenreLst);

            var movies = from m in db.Movies
                         select m;

            if (!String.IsNullOrEmpty(searchString))
            {
                movies = movies.Where(s => s.Title.Contains(searchString));
            }

            if (!string.IsNullOrEmpty(movieGenre))
            {
                movies = movies.Where(x => x.Genre == movieGenre);
            }

            var config = LogManager.Configuration;
            string basedirPath = AppDomain.CurrentDomain.BaseDirectory;
#if TRACE
            logger = NLog.LogManager.GetLogger("rule1");
            logger.Info("\n{0}", movies);
#endif
            return View(movies);
        }
開發者ID:chao1017,項目名稱:MVC5_Labs,代碼行數:33,代碼來源:MoviesController.cs

示例10: Main

        static void Main(string[] args)
        {
            Log = LogManager.GetCurrentClassLogger();

            Log.Info(
                String.Format("Version: {0} ({1} bit)\r\n ", RocksmithToolkitLib.ToolkitVersion.version, Environment.Is64BitProcess ? "64" : "32") +
                String.Format("OS: {0} ({1} bit)\r\n ", Environment.OSVersion, Environment.Is64BitOperatingSystem ? "64" : "32") +
                String.Format("Runtime: v{0}\r\n ", Environment.Version) +
                String.Format("JIT: {0}", JitVersionInfo.GetJitVersion())
            );

            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            AppDomain.CurrentDomain.UnhandledException += (s, e) =>
            {
                var exception = (Exception)e.ExceptionObject;
                MessageBox.Show(String.Format("Application.ThreadException\n{0}\n{1}\nPlease send us \"_RSToolkit_{2}.log\", you can find it in Toolkit folder.",
                    exception.ToString(), exception.Message.ToString(), DateTime.Now.ToString("yyyy-MM-dd")), "Unhandled Exception catched!");
                Log.ErrorException(String.Format("\n{0}\n{1}\nException catched:\n{2}\n", exception.Source, exception.TargetSite, exception.InnerException), exception);
            };

            // UI thread exceptions handling.
            Application.ThreadException += (s, e) =>
            {
                var exception = (Exception)e.Exception;
                MessageBox.Show(String.Format("Application.ThreadException\n{0}\n{1}\nPlease send us \"_RSToolkit_{2}.log\", you can find it in Toolkit folder.",
                    exception.ToString(), exception.Message.ToString(), DateTime.Now.ToString("yyyy-MM-dd")), "Thread Exception catched!");
                Log.ErrorException(String.Format("\n{0}\n{1}\nException catched:\n{2}\n", exception.Source, exception.TargetSite, exception.InnerException), exception);
            };

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(args));
        }
開發者ID:rscustom,項目名稱:rocksmith-custom-song-toolkit,代碼行數:33,代碼來源:Program.cs

示例11: TaskCoordinator

        public TaskCoordinator(IScheduler scheduler, Logger logger)
        {
            _logger = logger;
            _scheduler = scheduler;

            _logger.Info("TaskCoordincator started with scheduler: {0}", scheduler.SchedulerInstanceId);
        }
開發者ID:mamluka,項目名稱:SpeedyMailer,代碼行數:7,代碼來源:TaskCoordinator.cs

示例12: RegisterScriptEvents

		private static HashSet<string> RegisterScriptEvents(IEnumerable<PluginBase> plugins, Logger logger)
		{
			var scriptEvents = new HashSet<string>(StringComparer.CurrentCultureIgnoreCase);
			
			foreach (var plugin in plugins)
			{
				var properties = plugin.GetType()
					.GetProperties()
					.Where(m => m.PropertyType == typeof(ScriptEventHandlerDelegate[]))
					.ToList();

				foreach (var member in properties)
				{
					var eventInfo = member.GetCustomAttributes<ScriptEventAttribute>().SingleOrDefault();

					if (eventInfo != null)
					{
						logger.Info("register script event '{0}' ({1})", eventInfo.EventAlias, member);

						if (scriptEvents.Contains(eventInfo.EventAlias))
						{
							var message = string.Format("duplicate event alias: '{0}'", eventInfo.EventAlias);
							throw new Exception(message);
						}

						scriptEvents.Add(eventInfo.EventAlias);
					}
				}
			}

			return scriptEvents;
		}
開發者ID:3660628,項目名稱:thinking-home,代碼行數:32,代碼來源:ScriptsPlugin.cs

示例13: 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

示例14: Exit

 static void Exit(Logger logger, CancellationTokenSource src, ExtensionRunnerExitCode exitCode)
 {
     if(logger != null)
         logger.Info("Exiting (code: " + exitCode + ")");
     src.Cancel();
     Environment.Exit((int)exitCode);
 }
開發者ID:huoxudong125,項目名稱:ServerX,代碼行數:7,代碼來源:Program.cs

示例15: 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


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