示例#1
0
 /// <summary>
 /// 记录警告
 /// </summary>
 public static void LogWarn(AppOpLog opLog)
 {
     if (log.IsWarnEnabled)
     {
         log.Warn(opLog);
     }
 }
示例#2
0
 /// <summary>
 /// 记录严重错误
 /// </summary>
 public static void LogFatal(AppOpLog opLog, Exception ex)
 {
     if (log.IsFatalEnabled)
     {
         log.Fatal(opLog, ex);
     }
 }
示例#3
0
 /// <summary>
 /// 记录一般日志
 /// </summary>
 public static void LogInfo(AppOpLog opLog)
 {
     if (log.IsInfoEnabled)
     {
         log.Info(opLog);
     }
 }
示例#4
0
 /// <summary>
 /// 记录错误
 /// </summary>
 public static void LogError(AppOpLog opLog, Exception ex)
 {
     if (log.IsErrorEnabled)
     {
         log.Error(opLog, ex);
     }
 }
示例#5
0
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure(
                new System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory + "\\log4net.config")
                );

            AppOpLog opLog = new AppOpLog
            {
                UserPhone      = "18888888888",
                IP             = "192.124.0.0",
                ActionName     = "action",
                ControllerName = "controller",
                ActionParam    = "param",
                Url            = "url",
                HttpHeader     = "header",
                HttpMethod     = "get",
                UserAgent      = "useragent",
                StartTime      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                EndTime        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
            };

            opLog.RunTime = (Convert.ToDateTime(opLog.EndTime) - Convert.ToDateTime(opLog.StartTime)).TotalSeconds.ToString();

            LogHelper.LogInfo(opLog);

            Console.ReadKey();
        }