示例#1
0
 public static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror");//这里的 logerror 和 log4net.config 里的名字要一样
 public void WriteErrorLog(Exception ex, string method, string errorTable)
 {
     try
     {
         SqlSugarClient db    = DBSugar.MySqlInstance();
         TB_Error_log   error = new TB_Error_log();
         error.ErrorID      = Guid.NewGuid().ToString("D");
         error.ErrorMessage = ex.Message;
         error.ErrorMethod  = method;
         error.ErrorTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         error.ErrorTable   = errorTable;
         db.Saveable <TB_Error_log>(error).ExecuteCommand();
         logerror.Error("异常为:" + ex.Message + "========================方法是:" + method + "========================数据表为:" + errorTable);
     }
     catch (Exception e)
     {
         logerror.Error("异常为:" + e.Message + "========================方法是:" + method + "========================数据表为:" + errorTable);
     }
 }
示例#2
0
 public void WriteInforLog(string message, string method, string errorTable)
 {
     loginfo.Error("方法是:" + method + "========================数据表为:" + errorTable);
     try
     {
         SqlSugarClient db       = DBSugar.MySqlInstance();
         TB_Info_log    info_Log = new TB_Info_log();
         info_Log.InfoID      = Guid.NewGuid().ToString("D");
         info_Log.InfoMessage = message;
         info_Log.InfoMethod  = method;
         info_Log.InfoTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         info_Log.InfoTable   = errorTable;
         db.Saveable <TB_Info_log>(info_Log).ExecuteCommand();
     }
     catch (Exception ex)
     {
         error.WriteErrorLog(ex, method, errorTable);
     }
 }