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); }
public static Guid UniqueLogId(this RealNLog.LogEventInfo source) { if (source.Properties.ContainsKey("UniqueLogId")) { return((Guid)source.Properties["UniqueLogId"]); } return(Guid.Empty); }
public static object Data(this RealNLog.LogEventInfo source) { if (source.Properties.ContainsKey("Data")) { return(source.Properties["Data"]); } return(null); }
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); } }
public static void UniqueLogId(this RealNLog.LogEventInfo source, Guid value) { source.Properties["UniqueLogId"] = value; }
public static void Data(this RealNLog.LogEventInfo source, object value) { source.Properties["Data"] = value; }