RollLogFile

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]

SwitchDescription
/fFilename 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.
/aNumber of files to archive before deleting. Default is to keep the previous 3 log files.
/rFile 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.
/tNumber of attempts to try before aborting a file operation. Default is to try 3 times before aborting.
/uUse 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

ExampleDescription
RollLogFile /f:"C:\Some Application\LogFile.txt" /a:5 /r:60 /t:5This 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 /uThis command archives the '\\SERVER\Share\LogFile.txt' with underscores, up to 3 times using the default retry/timeout operations.

Download

Version: 1.2.0, Size: 187 kB

Testimonial

Iain Brighton and the team at Virtual Engine were key to the success of the Dynamic Desktop project, their advice and support ensured that we avoided unnecessary delay and that the whole project ran smoothly.

Chris Petrie, IT Director
Stephenson Harwood
2011 Logos Footer

Search Our Site