Files
“wanyongkang” ed3b2c653e 接口文件
2024-04-10 13:55:27 +08:00

59 lines
1.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using NLog;
namespace Hncore.Infrastructure.Common
{
public class LogHelper
{
private static readonly Logger Log = LogManager.GetLogger("UserLog");
private static string assName = AppDomain.CurrentDomain.FriendlyName;
private static string FormatMsg(string title, object msg)
{
return "Assembly" + assName + "\r\nTitle : " + title + "\r\nMessage : " + msg + "\r\n";
}
public static void Error(string title, object msg = null)
{
Log?.Error(FormatMsg(title, msg));
Console.WriteLine(DateTime.Now+"\r\n"+FormatMsg(title, msg));
}
public static void Debug(string title, object msg = null)
{
Log?.Debug(FormatMsg(title, msg));
Console.WriteLine(DateTime.Now+"\r\n"+FormatMsg(title, msg));
}
public static void Info(string title, object msg = null)
{
Log?.Info(FormatMsg(title, msg));
Console.WriteLine(DateTime.Now+"\r\n"+FormatMsg(title, msg));
}
public static void Warn(string title, object msg = null)
{
Log?.Warn(FormatMsg(title, msg));
Console.WriteLine(DateTime.Now+"\r\n"+FormatMsg(title, msg));
}
public static void Trace(string title, object msg = null)
{
Log?.Trace(FormatMsg(title, msg));
Console.WriteLine(DateTime.Now+"\r\n"+FormatMsg(title, msg));
}
public static void Fatal(string title, object msg = null)
{
Log?.Fatal(FormatMsg(title, msg));
Console.WriteLine(DateTime.Now+"\r\n"+FormatMsg(title, msg));
}
}
}