Rails log files rotate automatically when they reach approx. 100MB:
$ ls -lh log/
-rw-r--r-- 1 user group 55M Sep 15 09:54 development.log
-rw-r--r-- 1 user group 101M Aug 22 13:45 development.log.0
This behavior is
a built-in feature
Show archive.org snapshot
of Ruby's standard Logger
class, which Rails uses by default.
To control the maximum file size, set config.log_file_size
in your environment configuration. This is useful for keeping log files manageable, especially in development and test environments.
# config/environments/development.rb
Rails.application.configure do
config.log_file_size = 10.megabytes
end
When this value is set, Rails initializes the logger to rotate the log file and keep one old version, which is overwritten on the next rotation. In production, you could use periodic rotation Show archive.org snapshot to rotate log files every day for a week or something similar.
Posted by Michael Leimstädtner to makandra dev (2025-09-17 11:17)