Introduction

Some applications will offer the ability to write debugging information to a log file. Unfortunately only some applications will maintain the size of the log file(s) or provide some archiving capability. The rest we have to manually maintain the files or delete them on a periodic basis. This is why RollLogFile has been developed.

Each time the RollLogFile process is run the log file(s) will be appended with a period. The higher the number the older the log file. For example, a log file called LogFile.txt will be renamed to LogFile.1.txt or LogFile_1.txt. The next time it’s run the file will be renamed to either LogFile.2.txt or LogFile_2.txt (the new LogFile.txt will also be renamed to either LogFile.1.txt or LogFile_1.txt).

RollLogFile, when used in conjuntion with the Windows Task Scheduler, can take some of the pain out of managing these files providing an audit trail without running out of disk space. The power of RollLogFile is its ability to retry the rename operations numerous times before giving up. It will all depend on how active the log files are as to how many retires will be required.

Installation

Just copy RollLogFile on to your executable path. Typing “RollLogFile /?” displays its usage syntax.

Using RollLogFile

Usage: RollLogFile /f:LogFile [/a:FilesToArchive] [/r:RetryInterval] [/t:Attempts] [/u]

Switch Description
/f Filename of the log file to roll. UNC paths can also be used. Note: spaces in the file name need to be enclosed with quotation (") marks.
/a Number of files to archive before deleting. Default is to keep the previous 3 log files.
/r File delete/rename timeout in seconds. Default is to wait 10 seconds. If there is a lock on the file and it can't be renamed/deleted the process will be attempted again after the specified number of seconds.
/t Number of attempts to try before aborting a file operation. Default is to try 3 times before aborting.
/u Use underscores instead of periods as a denominator. The default mode is to use periods for rename operations, for example, logfile.1.txt and logfile.2.txt. Using the /u switch changes the behaviour to underscores. For example, logfile_1.txt and logfile_2.txt.

Examples

Example Description
RollLogFile /f:"C:\Some Application\LogFile.txt" /a:5 /r:60 /t:5 This command archives the 'C:\Some Application\LogFile.txt' up to five times. The rename operations will be retried 5 times at 60 second intervals.
RollLogFile /f:\\SERVER\Share\LogFile.txt /u This command archives the '\\SERVER\Share\LogFile.txt' with underscores, up to 3 times using the default retry/timeout operations.

[download id=”1″ format=”1″]

Archives

Categories