/// <summary> /// Ages and prunes the log based on the System.MaxLogEntries and System.MaxLogDays AppConfigs /// </summary> private void Age() { var currentErrors = DB.GetSqlN("select count(*) as N from aspdnsf_SysLog"); var earliestDayToKeep = DateTime.Now.AddDays((MaxLogDays * -1)); DB.ExecuteSQL(string.Format("delete from aspdnsf_syslog where createdon < {0}", DB.SQuote(Localization.DateStringForDB(earliestDayToKeep)))); //Make space for new entries var entriesToDelete = currentErrors - MaxLogEntries; if (entriesToDelete > 0) { DB.ExecuteSQL(string.Format("delete from aspdnsf_syslog where SysLogID in (select top {0} SysLogID from aspdnsf_syslog order by createdon)", entriesToDelete + 5)); } }
/// <summary> /// Ages and prunes the log based on the System.MaxLogEntries and System.MaxLogDays AppConfigs /// </summary> private void Age() { int currentErrors = DB.GetSqlN("select count(*) as N from aspdnsf_SysLog"); DateTime earliestDayToKeep = System.DateTime.Now.AddDays((this.MaxLogDays * -1)); DB.ExecuteSQL("delete from aspdnsf_syslog where createdon < " + DB.SQuote(Localization.DateStringForDB(earliestDayToKeep))); //Make space for new entries int entriesToDelete = currentErrors - this.MaxLogEntries; if (entriesToDelete > 0) { DB.ExecuteSQL("delete from aspdnsf_syslog where SysLogID in (select top " + (entriesToDelete + 5) + " SysLogID from aspdnsf_syslog order by createdon)"); } }