Johan Känngård » batch http://johankanngard.net Useful tips for developers Thu, 19 May 2011 18:40:56 +0000 en hourly 1 http://wordpress.org/?v=3.0.1 Log File Roller For Microsoft Windows http://johankanngard.net/2008/12/11/log-file-roller-for-microsoft-windows/ http://johankanngard.net/2008/12/11/log-file-roller-for-microsoft-windows/#comments Thu, 11 Dec 2008 13:50:43 +0000 Johan Känngård http://johankanngard.net/?p=330 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! :-)

Usage:

rollLog LOGDIRECTORY LOGFILENAME

For instance, if you have a log at c:\log\at.log, you can run:

rollLog c:\logs at.log

Afterwards, you have one file named c:\logs\at.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.

The rollLog.cmd file is here!

]]>
http://johankanngard.net/2008/12/11/log-file-roller-for-microsoft-windows/feed/ 1