private static bool TryLoadFromWorkDir(string fileName)
        {
            var pathToCheck = Path.Combine(Directory.GetCurrentDirectory(), fileName);

            if (File.Exists(pathToCheck))
            {
                NLogManager.Configuration = new XmlLoggingConfiguration(pathToCheck);
                NLogManager.ReconfigExistingLoggers();
                return(true);
            }
            return(false);
        }
示例#2
0
        protected override void WriteLine(string line, params string[] args)
        {
            if (this.metricType == null || this.metricName == null)
            {
                return;
            }

            var loggerName = string.Format("Metrics.Text.{0}.{1}", this.metricType, this.metricName);
            var logEvent   = LogEventInfo.Create(LogLevel.Info, loggerName, string.Format(line, args));

            logEvent.Properties.Add("MetricType", CleanFileName(metricType));
            logEvent.Properties.Add("MetricName", CleanFileName(metricName));
            LogManager.GetLogger(loggerName).Log(logEvent);
        }
        public Task FlushAsync(TimeSpan timeout)
        {
            var tcs = new TaskCompletionSource <object>();

            NLogManager.Flush(
                e =>
            {
                if (e != null)
                {
                    tcs.TrySetException(e);
                }
                else
                {
                    tcs.TrySetResult(null);
                }
            },
                timeout);
            return(tcs.Task);
        }
        public ILog GetLogger(Type type)
        {
            var logger = NLogLogManager.GetLogger(type.FullName);

            return(new Logger(logger));
        }
        public ILog GetLogger(string name)
        {
            var logger = NLogLogManager.GetLogger(name);

            return(new Logger(logger));
        }
 public void Flush()
 {
     NLogManager.Flush();
 }
 public void Flush(TimeSpan timeout)
 {
     NLogManager.Flush(timeout);
 }
 public ILogger Create(string name)
 {
     return(new Logger(NLogManager.GetLogger(name)));
 }
示例#9
0
        public override void AppendLine(DateTime timestamp, string metricType, string metricName, IEnumerable <CSVReport.Value> values)
        {
            var loggerName = $"Metrics.CSV.{metricType}.{metricName}";

            LogManager.GetLogger(loggerName).Log(GetLogEvent(loggerName, timestamp, metricType, metricName, values));
        }