using log4net; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace VueWebApi.Log4net { public class LogUtil { public LogUtil() { } private static ActionLoggerInfo _message = null; private static log4net.ILog _log; public static log4net.ILog Log { get { if (_log == null) { _log = LogManager.GetLogger("OperateLogger"); } return _log; } } public static void Debug() { if (Log.IsDebugEnabled) { Log.Debug(_message); } } public static void Error() { if (Log.IsErrorEnabled) { Log.Error(_message); } } public static void Fatal() { if (Log.IsFatalEnabled) { Log.Fatal(_message); } } public static void Info() { if (Log.IsInfoEnabled) { Log.Info(_message); } } public static void Warn() { if (Log.IsWarnEnabled) { Log.Warn(_message); } } /// /// 操作记录调用方法 /// /// 操作类型 /// 操作类容 /// 操作方法 /// ip地址 /// 操作人员 public static void SaveMessage(string op_type, string op_content, string actionclick,string ippath,string lm_user, int level) { _message = new ActionLoggerInfo(op_type, op_content, actionclick, ippath, lm_user, level); switch (level) { case 1: Info(); break; case 2: Warn(); break; case 3: Error(); break; case 4: Fatal(); break; default: break; } } } }