Ruby on rails log file size too large

2019-03-09 17:28发布

I stumbled to learn that my rails3.1 log file is super large, around 21mb. Is this, in terms of size normal? What the log file would like in the production environment? Besides, can I get rid of the log?thanks

8条回答
疯言疯语
2楼-- · 2019-03-09 18:23

you can just delete the file!
Rails will create a new log if one doesn't exist.
Obviously save / backup the file if it's important, but usually it's not.
You can also zip the backuped up file (and then delete the source) if you want to keep it on the same drive but still save space.

To automatically rotate log files (the best long-term solution) use log rotate as described here:

Ruby on Rails production log rotation

then you can set it and forget it!

To actually change what gets logged see:

http://dennisreimann.de/blog/silencing-the-rails-log-on-a-per-action-basis/

查看更多
Juvenile、少年°
3楼-- · 2019-03-09 18:25

I automatically clear the logs in development on each server start with config/initializers/clear_development_log.rb:

if Rails.env.development?
  `rake log:clear`
end
查看更多
登录 后发表回答