/// <summary> /// 跟踪数据执行语句 /// </summary> /// <param name="commandText">数据执行语句</param> protected void CommandTrackLog(string commandText) { if (trackInfo.IsTrackOpen) { LogEntry logEntry = new LogEntry(); logEntry.Message = commandText; logEntry.Title = "数据库语句"; logEntry.TimeStamp = DateTime.Now; logEntry.ErrorLevelInfo = ErrorLevel.Info; logEntry.LogTypeInfo = LogType.DBCommandTrackLog; LogPosition logPosition = trackInfo.LogPositionInfo; SysLogger.Write(logEntry, trackInfo.LogPositionInfo, trackInfo.LogPath); } }
/// <summary> /// 记录数据库执行异常日志 /// </summary> /// <param name="exception">异常</param> /// <param name="commandText">sql语句</param> protected void ExceptionLog(Exception exception, string commandText) { if (exceptionConfigInfo.IsExceptionLogOpen) { LogEntry logEntry = new LogEntry(); logEntry.Message = exception.Message + ";错误语句:" + commandText; logEntry.Title = "数据库操作异常"; logEntry.TimeStamp = DateTime.Now; logEntry.LogTypeInfo = LogType.ExceptionLog; logEntry.ErrorLevelInfo = ErrorLevel.Error; logEntry.StackTrace = exception.StackTrace; SysLogger.Write(logEntry, exceptionConfigInfo.LogPositionInfo, exceptionConfigInfo.LogPath); } }