Jump to content

How to limit the size of a log file

Recommended Posts

I plan to create a log file for my scripts using _FileWriteLog function, my problem is if I already foresee that the log will grow up quickly due to new log keep coming in anytime 24H a day, what is the best way to limit the size of the log? already search the forum but seem not many discussions about this topic (maybe it's too simple :ph34r:)

Following is the ways I know:

(1) One expert in the forum achieve this by runing an extra script thread to monitor size of the log file, once found it over the limit, delete log file.

(2) Periodically open log file using _FileReadToArray, check the value of element #0 (total number of lines), if it over the limit, delete unwanted lines.

(3) Using FIFO method eachtime when the new log being written into the log file.

Any suggestion? Many thanks.

Edited by tktk
Link to post
Share on other sites

If you expect a high volume of data to be passed to a log file on a daily/ weekly basis, just rotate the logs. I do that for my FTP server logs, since I can have up to 1 or 2 MB of logs per day. The result is not only that your logs are split to prevent large files, but they also become eaisier to sort and search through. This method also allows you to compressed old, no longer in use log files. Most textual log files can be compressed anywhere from 50-90%

Edit: Reading my post again, I didn't describe it very well :\. By "rotate" I mean put the date in the log file. I personally like the format YYYY-MM-DD-something.log because it will then appear sorted by date no matter how log you run the logs for.

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to post
Share on other sites

Thank you Pekster.

How to manage well is always more important and effective then how to code well :ph34r: espeically when using AutoIt, a great tool that powerful but relatively easy on coding. I am a little familiar with VB, tried AutoIt 3 days ago, and I love it now.

Your info. is very precious to me.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...