Skip to content

Instantly share code, notes, and snippets.

@pvin
Last active February 2, 2024 10:18
Show Gist options
  • Save pvin/00e0bd0b8939a6c9d1ce405875e447fa to your computer and use it in GitHub Desktop.
Save pvin/00e0bd0b8939a6c9d1ce405875e447fa to your computer and use it in GitHub Desktop.
Ruby on Rails production log rotation
# Log Rotate by initialising logger from the app
#Way one
# reference : http://ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html#method-c-new
# This one from Atinder Singh https://medium.com/@atinders/easy-log-rotation-with-rails-5-7b8d3c173461
# config/environments/production.rb
Rails.application.configure do
config.logger = Logger.new(config.paths["log"].first, 5, 10.megabytes)
end
# Number of files : 5
# Maximum file size : 10.megabytes
#Way two
# Alternate way with log rotate
# https://gorails.com/guides/rotating-rails-production-logs-with-logrotate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment