Rails Logger -Rails logrotate automatically

i am using like this, config.logger = Logger.new(Rails.root.join('log', "#{Rails.env}.log"), 10, 10*1024). Its working perfectly.It clear the log the file reach 10240bytes.

i taken back up of the log file, the name of the file is "development.log.0","development.log.1".. Now i want "development.log.0.2012-09-24"(that is i want to add Time.now at the end of the file name. Can any one help me??

Upvotes: 1

Views: 180

Answers (2)

Olly
Olly

Reputation: 7758

This is entirely dependent upon the stack you're deploying to, but I'm of the opinion that rotating logs shouldn't be a concern of your Rails app. I would recommend doing this at the OS level using logrotate (if you're on *nix) scheduled daily via cron.

http://linuxcommand.org/man_pages/logrotate8.html

Upvotes: 1

suvankar
suvankar

Reputation: 1558

Try this

config.logger = Logger.new(Rails.root.join('log', "#{Rails.env}.log.#{Date.today.to_s}"), 10, 10*1024)

Upvotes: 0

Related Questions