My application creates a log, as a text file, to record various events. I append new entries, just a line of text, to the end of the file. I would like to keep the log from growing over a certain size. I was hoping that there was a way to delete the first line of text from the file (which would be the oldest entry) when the log gets to a certain byte size. Thereby 'bumping' the rest of the file contents 'up.'
The only thing I can come up with is to read the whole dang log into memory remove the entry, add the new one and write the whole log back to the file. There has got to be a more efficient method to do this.