Need advice with log file
Posted on 2009-06-29
I'm using VB 2005, WinForms. I have a procedure that logs events that I need logged in my application. The procedure works nicely for my needs. It produces a text log file that is nothing more than line entries on a page - a typical event logger, one entry after the other.
Currently, the procedure does not terminate the log file, so the file could theoretically grow and grow in size without limits. -- Here's where I need advice:
1). Is there a way to have the file grow to a certain size (perhaps 500 entries long) and then begin to delete the oldest entry, so that it can add a new one - like FIFO?
2). Would it be better (or easier) to close the log file out at 500 entries and start a new file like the old Unix logs that logged up to 10 files of history (i.e. log01, log02, log03...etc)?
Has anyone worked on anything like this, who can provide advice and perhaps some sample code?