I have a logging application that works great, but I want to apply the ability to maintain the size of the log file - stop it from getting too large.
Ideally, I want to check the size of the file periodically, and if it's over the configured amount (5MB or something) delete from the beginning till it reaches some size, like 4MB.
From reading other questions I'm still unclear if I can update/delete a file without reading it's entire contents. My ideal situation would be:
if(filesize > 5MB)
{
while(filesize > 4MB)
Delete_First_X_Many_Lines(file);
}
Thankyou in advance for any pointers and direction.