A simple log file roller, that rolls/rotates a file from FILENAME.0, to FILENAME.1, onwards to FILENAME.9. If FILENAME.9 exists, it is deleted. Can be used to keep log files small and managable, and delete old ones. The code is not pretty, I could not get it work with loops. If anyone has a better way of doing this, please let me know! 🙂
rollLog LOGDIRECTORY LOGFILENAME
For instance, if you have a log at c:logat.log, you can run:
rollLog c:logs at.log
Afterwards, you have one file named c:logsat.log.0. The next time you run it (and there has been something written to at.log) you get two files, at.log.0 and at.log.1.