本文整理汇总了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());
}
}
示例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("-----------");
}
}
示例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));
}
示例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;
}
示例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();
}
示例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
}
}
示例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();
}
示例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;
}
示例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);
}
示例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));
}
示例11: TaskCoordinator
public TaskCoordinator(IScheduler scheduler, Logger logger)
{
_logger = logger;
_scheduler = scheduler;
_logger.Info("TaskCoordincator started with scheduler: {0}", scheduler.SchedulerInstanceId);
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
});
}