Dec
11
Posted on 2008-12-11
Filed Under (Programming, Windows) by Johan Känngård

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!

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
(1) Comment    Read More   

Comments

Sofie on 27 April, 2009 at 16:32:33 #

Oj, här var jag nog fel målgrupp :-) Men som svar på ditt inlägg: ja, det går inte så snabbt när man ligger still på gräset ;-)


Post a Comment
Name:
Email:
Website:
Comments: