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="actionclick">接口方法</param>
|
/// <param name="usercode">用户编码</param>
|
/// <param name="userip">用户ip</param>
|
/// <param name="level">日志等级</param>
|
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;
|
}
|
}
|
}
|
}
|