public virtual void Log(LogEntry entry) { foreach (ILogWriter writer in Writers ) { if (writer.IsEnabled && entry.Level >= writer.Level) writer.Write(entry); } }
/// <summary> /// Writes a log entry to the underlying log4net logger. /// </summary> /// <param name="entry">The entry to log.</param> public void Write(LogEntry entry) { if (!this.IsEnabled || this.Level > entry.Level || entry == null) return; switch (entry.Level) { case LogLevel.Debug: _logger.Debug(entry.Message); break; case LogLevel.Info: _logger.Info(entry.Message); break; case LogLevel.Error: _logger.Error(entry.Message); break; case LogLevel.Fatal: _logger.Fatal(entry.Message); break; default: break; } }
/// <summary> /// Writes the log entry to a medium. /// </summary> /// <param name="entry">The entry to log.</param> /// <param name="flush">A value indicating whether the writer should call Flush after writing to the TextWriter.</param> public void Write(LogEntry entry, bool flush) { if (!this.IsEnabled || this.Level > entry.Level || entry == null) return; Writer.WriteLine(entry.ToString(string.Empty, "yyyy-MM-dd HH:mm:ss")); if (flush || this.AutoflushLevel <= entry.Level) Flush(); }
/// <summary> /// Writes the log entry to a medium. Equivalent to calling Write(entry, false). /// </summary> /// <param name="entry">The entry to log.</param> public void Write(LogEntry entry) { this.Write(entry, false); }
public void TestToString() { DateTime time = new DateTime(2009, 05, 31, 20, 5, 36); LogEntry entry = new LogEntry(time) { Message = "message", Level = LogLevel.Fatal }; Assert.AreEqual(string.Format("FATAL - {0} {1} - message", time.ToShortDateString(), time.ToShortTimeString()), entry.ToString()); }
public void Write(LogEntry entry) { if (!this.IsEnabled || this.Level > entry.Level || entry == null) return; Writer.WriteLine(entry.ToString()); }
public void Log(LogEntry entry) { Log(entry.Message, entry.Level); }
/// <summary> /// Writes the log entry to a medium. Equivalent to calling Write(entry, false). /// </summary> /// <param name="entry">The entry to log.</param> public void Write(LogEntry entry) { this.Write(entry, false); }