By default, Ruby on Rails writes to the same development log, located at log/development.log indefinitely. This can lead to a large log file. Fortunately, it’s possible to rotate this log file without having to depend on any external applications, like syslog. Here’s how:

  1. Add the following to your config/environments/development.rb file. Feel free to replace “daily” with your preferred interval, like “weekly”, or “monthly”:

    config.logger = Logger.new("log/#{Rails.env}.log", "daily")

  2. Restart Rails:

    touch tmp/restart.txt

That’s it! While you’re at it, you’ll probably also want to rotate your test.log file. You can do so by editing config/environments/test.rb, and applying the same update that’s shown above for config/environments/development.rb.