Merge branch 'release/LogCleanupReview'
This commit is contained in:
@@ -634,6 +634,9 @@ namespace IOB_UT_NEXT
|
||||
fileMover.obj.eliminaFile(_file);
|
||||
}
|
||||
}
|
||||
// inizio con eliminare file + vecchi della data indicata...
|
||||
int maxLogDays = CRI("maxLogDays");
|
||||
fileMover.obj.deleteOlderThan(maxLogDays);
|
||||
// ora controllo SE sia superata la dim max della directory --> in tal caso cancello dal + vecchio...
|
||||
dirSizeMb = fileMover.obj.totalMb();
|
||||
int maxLogDirSize = CRI("maxLogDirSize");
|
||||
|
||||
@@ -2,6 +2,7 @@ using ICSharpCode.SharpZipLib.Zip;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
|
||||
@@ -540,6 +541,24 @@ namespace IOB_UT_NEXT
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
/// <summary>
|
||||
/// Elimina i file + vecchi di maxNumDays giorni
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public void deleteOlderThan(int maxNumDays)
|
||||
{
|
||||
DirectoryInfo _di = checkDir();
|
||||
FileInfo[] _fis = _di.GetFiles();
|
||||
DateTime dateLimit = DateTime.Now.AddDays(-maxNumDays);
|
||||
try
|
||||
{
|
||||
_fis.Where(x => x.LastWriteTime <dateLimit).ToList().ForEach(x => x.Delete());
|
||||
}
|
||||
catch(Exception exc)
|
||||
{
|
||||
Logging.Instance.Error($"Eccezione in deleteOlderThan{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// elenco dei files come array di oggetti FileInfo
|
||||
|
||||
@@ -88,7 +88,8 @@
|
||||
<add key="verbose" value="true" />
|
||||
<add key="logEvery" value="100" />
|
||||
<add key="zipLogOldDay" value="1" />
|
||||
<add key="maxLogDirSize" value="400" />
|
||||
<add key="maxLogDirSize" value="300" />
|
||||
<add key="maxLogDays" value="120" />
|
||||
<add key="numRowConsole" value="50" />
|
||||
<add key="verboseLogTOut" value="60" />
|
||||
<!--conf x FANUC-->
|
||||
|
||||
Reference in New Issue
Block a user