Rails logrotate automatically

My production log 1GB, i need to setup logrotate automatically when the size reaches 1GB. I am using rails 3, ruby 1.9.3. How to rotate the log in rails? Can any one help me out? Thanks in advance.

Upvotes: 1

Views: 230

Answers (1)

steenslag
steenslag

Reputation: 80105

To create a logger which ages logfile once it reaches about 102,400,000 bytes and leave 10 old log files:

require 'logger'
logger = Logger.new('foo.log', 10, 102_400_000) #10 logs, about 1 GB all together

Upvotes: 2

Related Questions