// I/F public void Append(ref LogEvent logEvent) { Debug.WriteLine("{0:HH:mm:ss.fffffff} [{1,2}] {2,-5} {3} - {4}", logEvent.DateTime, logEvent.ThreadId, levelStrings[(int) logEvent.Level], logEvent.Category, logEvent.Message); if (logEvent.Exception != null) AppendException(logEvent.Exception); }
// I/F public void Append(ref LogEvent logEvent) { #if WINDOWS lock (this) { Trace.Write(logEvent.DateTime.ToString("HH:mm:ss.fffffff")); Trace.Write(string.Format(" [{0,2}] ", logEvent.ThreadId)); Trace.Write(string.Format("{0,-5} ", levelStrings[(int) logEvent.Level])); Trace.Write(" "); Trace.Write(logEvent.Category); Trace.Write(" - "); Trace.WriteLine(logEvent.Message); if (logEvent.Exception != null) AppendException(logEvent.Exception); Trace.Flush(); } #endif }
void Log(LogLevel level, Exception exception, string message, params object[] arg) { if (Appender == null) return; if (arg != null && arg.Length != 0) message = string.Format(message, arg); var logEvent = new LogEvent { Level = level, Category = category, DateTime = DateTime.Now, ThreadId = Thread.CurrentThread.ManagedThreadId, Message = message, Exception = exception }; Appender.Append(ref logEvent); }