In case anyone is interested, I added the following to clear log files after "x" days. It seems to be working well.
Added LogFilesToKeep to Web.Config with a value of "21"
Created the method below in util.cs;
public static void clearLoggingFiles()
{
int lnDaysToKeep = Convert.ToInt16(Util.get_setting("LogFilesToKeep","21"));
string[] laFiles = Directory.GetFiles(Util.get_log_folder());
foreach (string lsFile in laFiles)
{
FileInfo loFileInfo = new FileInfo(lsFile);
if (loFileInfo.LastWriteTime < DateTime.Now.AddDays(-lnDaysToKeep))
{
try
{
loFileInfo.Delete();
}
catch (Exception ex)
{
write_to_memory_log(ex.Message + "; Error deleting old log files.");
}
}
}
}
Modified write_to_log() in util.cs to call clearLoggingFiles()
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In case anyone is interested, I added the following to clear log files after "x" days. It seems to be working well.
Added LogFilesToKeep to Web.Config with a value of "21"
Created the method below in util.cs;
public static void clearLoggingFiles()
{
int lnDaysToKeep = Convert.ToInt16(Util.get_setting("LogFilesToKeep","21"));
string[] laFiles = Directory.GetFiles(Util.get_log_folder());
Modified write_to_log() in util.cs to call clearLoggingFiles()
thanks