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);
|
}
|
}
|
|
/// <summary>
|
/// 操作记录调用方法
|
/// </summary>
|
/// <param name="op_type">操作类型</param>
|
/// <param name="op_content">操作类容</param>
|
/// <param name="actionclick">操作方法</param>
|
/// <param name="ippath">ip地址</param>
|
/// <param name="lm_user">操作人员</param>
|
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;
|
}
|
}
|
}
|
}
|