using log4net; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MW_Log { /// /// LoggerHelper /// public class LoggerHelper { public static event Action ShowMsg; // 显示日志事件 /// /// LogInfo /// private static readonly ILog LogInfo = LogManager.GetLogger("LogInfo"); /// /// 记录Info日志 /// /// /// public static void Info(string type, string msg, Exception ex = null) { if (ex == null) ShowMsg?.Invoke(type, msg); else ShowMsg?.Invoke(type, ex.Message); msg = $"【类别:{type}】\r\n【内容】:{msg}"; if (ex != null) { LogInfo.Info(msg, ex); } else { LogInfo.Info(msg); } } } }