Exemplo n.º 1
0
        public static RealNLog.LogEventInfo FromLogEntry(LogEntryInfo entry)
        {
            var info = new RealNLog.LogEventInfo()
            {
                Exception = entry.Exception,
                Level     = ToNLogLevel(entry.Level),
                Message   = entry.Message,
                TimeStamp = entry.TimeStamp
            };

            info.LoggerName = entry.LoggerName;

            if (entry.Data != null)
            {
                info.Data(entry.GetFormattedData());
            }

            if (entry.StackTrace != null)
            {
                info.SetStackTrace(entry.StackTrace, 0);
            }

            info.UniqueLogId(entry.Id);

            return(info);
        }
Exemplo n.º 2
0
        public static Guid UniqueLogId(this RealNLog.LogEventInfo source)
        {
            if (source.Properties.ContainsKey("UniqueLogId"))
            {
                return((Guid)source.Properties["UniqueLogId"]);
            }

            return(Guid.Empty);
        }
Exemplo n.º 3
0
        public static object Data(this RealNLog.LogEventInfo source)
        {
            if (source.Properties.ContainsKey("Data"))
            {
                return(source.Properties["Data"]);
            }

            return(null);
        }
Exemplo n.º 4
0
        protected override void Write(global::NLog.LogEventInfo logEvent)
        {
            var logLevel = logEvent.Level;
            var msg      = this.Layout.Render(logEvent);

            if (logLevel >= LogLevel.Error)
            {
                Trace.TraceError(msg);
            }
            else if (logLevel >= LogLevel.Warn)
            {
                Trace.TraceWarning(msg);
            }
            else if (logLevel >= LogLevel.Info)
            {
                Trace.TraceInformation(msg);
            }
            else
            {
                Trace.WriteLine(msg);
            }
        }
Exemplo n.º 5
0
 public static void UniqueLogId(this RealNLog.LogEventInfo source, Guid value)
 {
     source.Properties["UniqueLogId"] = value;
 }
Exemplo n.º 6
0
 public static void Data(this RealNLog.LogEventInfo source, object value)
 {
     source.Properties["Data"] = value;
 }