From 5c76c23aad54891cfc54d401303262650d45cdc1 Mon Sep 17 00:00:00 2001 From: niushuai233 Date: Sun, 18 Sep 2022 16:33:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Util/LogUtil.cs | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Util/LogUtil.cs diff --git a/Util/LogUtil.cs b/Util/LogUtil.cs new file mode 100644 index 0000000..13c6f62 --- /dev/null +++ b/Util/LogUtil.cs @@ -0,0 +1,114 @@ +using log4net; +using System; + +namespace Util +{ + public class LogUtil + { + /// + /// 默认log实例 + /// + private static ILog LOG = LogManager.GetLogger("Console"); + + /// + /// 默认控制台logger debug + /// + /// 输出内容 + public static void Debug(string message) + { + LOG.Debug(message); + } + /// + /// 默认控制台logger debug + /// + /// 输出内容 + /// 异常堆栈 + public static void Debug(string message, Exception exception) + { + LOG.Debug(message, exception); + } + /// + /// 默认控制台logger info + /// + /// + public static void Info(string message) + { + LOG.Info(message); + } + /// + /// 默认控制台logger info + /// + /// 输出内容 + /// 异常堆栈 + public static void Info(string message, Exception exception) + { + LOG.Info(message, exception); + } + /// + /// 默认控制台logger warn + /// + /// 输出内容 + public static void Warn(string message) + { + LOG.Warn(message); + } + + /// + /// 默认控制台logger warn + /// + /// 输出内容 + /// 异常堆栈 + public static void Warn(string message, Exception exception) + { + LOG.Warn(message, exception); + } + + /// + /// 默认控制台logger error + /// + /// 输出内容 + public static void Error(string message) + { + LOG.Error(message); + } + + /// + /// 默认控制台logger error + /// + /// 输出内容 + /// 异常堆栈 + public static void Error(string message, Exception exception) + { + LOG.Error(message, exception); + } + + /// + /// 默认控制台logger fatal + /// + /// 输出内容 + public static void Fatal(string message) + { + LOG.Fatal(message); + } + + /// + /// 默认控制台logger fatal + /// + /// 输出内容 + /// 异常堆栈 + public static void Fatal(string message, Exception exception) + { + LOG.Fatal(message, exception); + } + + /// + /// 获取指定的logger + /// + /// + /// + public static ILog GetLogger(string loggerNmae) + { + return LogManager.GetLogger(loggerNmae); + } + } +}