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 actionclick, string usercode, string userip,int level)
{
_message = new ActionLoggerInfo(actionclick, usercode, userip, level);
switch (level)
{
case 1: Info(); break;
case 2: Warn(); break;
case 3: Error(); break;
case 4: Fatal(); break;
default: break;
}
}
}
}