You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

51 lines
1.4 KiB

using NLog;
using System;
namespace Mirle.Component.Record
{
/// <summary>
/// 記錄及顯示擴充方法類別
/// </summary>
public static class LogConsoleExtension
{
/// <summary>
/// 紀錄及顯示訊息
/// </summary>
/// <param name="log">記錄器</param>
/// <param name="message">紀錄訊息</param>
/// <param name="loglevel">紀錄等級</param>
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);
}
}
}
}