Reputation: 44
I have a program which logs its activity.
I want to implement a log file mechanism to keep the log file under a certain size, lets say 10 MB.
The log file itself just holds commands the program executed; those commands are variable length.
Right now, the program runs on a windows environment, but I'm likely to port it to UNIX soon.
1. Keep multiple files of lower size, and if the new command exceeds the current file length, truncate the oldest file to zero size, and start writing there.
2. Keep a header in the file, which holds metadata regarding the first command in the file, and the next place to write to in the file. Also I think, each command should hold metadata about it's length this way.
My questions are as follows:
Thanks a lot for your help,
Nihil.
Upvotes: 0
Views: 613
Reputation: 585
On UNIX/Linux platforms there's a logrotate program that manages logfiles. Details can be found for example here: http://linuxcommand.org/man_pages/logrotate8.html
Upvotes: 1