LoggerRemoveLogs Method
Removes the oldest non-read-only log files in a directory.
Namespace: Logging.HelperAssembly: Logging.Helper (in Logging.Helper.dll) Version: 2.0.6
public bool RemoveLogs(
string directory,
string logNameMask,
int maxFiles = 0
)
- directory String
- Directory containing the log files.
- logNameMask String
- Search pattern in the form [LogFile]*.[ext] of the log file names.
- maxFiles Int32 (Optional)
- Maximum number of log files to keep.
Boolean if any log files have been removed, otherwise
is returned.
In a method that needs to remove old log files:
var directory = @"C:\Temp\Logs" );
const string mask = "LogfileName*.log";
const int maxLogFiles = 50;
logging.RemoveLogs( directory, mask, maxLogFiles );