public void Log(LogEntry entry) { switch (entry.EventType) { case LoggingEventType.Error: case LoggingEventType.Fatal: Console.ForegroundColor = ConsoleColor.Red; break; case LoggingEventType.Warn: Console.ForegroundColor = ConsoleColor.DarkRed; break; case LoggingEventType.Debug: Console.ForegroundColor = ConsoleColor.Gray; break; case LoggingEventType.Info: default: Console.ForegroundColor = ConsoleColor.White; break; } Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.ffff|") + "{0}[{1}] {2}", name, entry.EventType.ToString(), entry.Message); if (entry.Exception != null) { Console.WriteLine("Exception: " + entry.Exception.GetType()); Console.WriteLine(entry.Exception.Message); Console.WriteLine(entry.Exception.StackTrace); } }
public void Log(LogEntry entry) { switch (entry.EventType) { case LoggingEventType.Debug: if (entry.Exception == null) { logger.Debug(entry.Message); } else { logger.Debug(entry.Exception, entry.Message); } break; case LoggingEventType.Info: if (entry.Exception == null) { logger.Info(entry.Message); } else { logger.Info(entry.Exception, entry.Message); } break; case LoggingEventType.Warn: if (entry.Exception == null) { logger.Warn(entry.Message); } else { logger.Warn(entry.Exception, entry.Message); } break; case LoggingEventType.Error: if (entry.Exception == null) { logger.Error(entry.Message); } else { logger.Error(entry.Exception, entry.Message); } break; case LoggingEventType.Fatal: if (entry.Exception == null) { logger.Fatal(entry.Message); } else { logger.Fatal(entry.Exception, entry.Message); } break; } }