Logfiles getting big? Rotate them automatically!

config.logger = Logger.new(config.log_path, 3, 10 * 1024**2)

Logfiles can get 10mb big, than they will be renamed to e.g. production.log.0 and if there are more than 3 of them they get deleted.
Maximum filesystem usage: 30mb

An alternative is using logrotate which is a harder to setup and maintain, but offers more options.

4 thoughts on “Logfiles getting big? Rotate them automatically!

  1. I am pretty satisfied with Rails logging as it is, now that my logfiles size is limited, but ill have a look what the logging gem can do for me 🙂

  2. I believe if you use this approach with mongrel, your mongrels will all try to rotate the file at the same time, causing all but the first mongrel to rotate the log to indefinitely block (lock up).

    John

  3. sounds possible, but so far we did not encounter the problem and i hope the logger developers too care of it since it is an obvious problem.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s