using NLog; using System; namespace Mirle.Component.Record { /// /// 記錄及顯示擴充方法類別 /// public static class LogConsoleExtension { /// /// 紀錄及顯示訊息 /// /// 記錄器 /// 紀錄訊息 /// 紀錄等級 public static void LogConsole(this Logger log, string message, LogLevel loglevel) { if (loglevel == LogLevel.Info) { Console.WriteLine(message); log.Info(message); } else if (loglevel == LogLevel.Debug) { Console.WriteLine(message); log.Debug(message); } else if (loglevel == LogLevel.Trace) { Console.WriteLine(message); log.Trace(message); } else if (loglevel == LogLevel.Warn) { Console.WriteLine(message); log.Warn(message); } else if (loglevel == LogLevel.Error) { Console.WriteLine(message); log.Error(message); } else { Console.WriteLine(message); log.Fatal(message); } } } }