preamble
Even on mid-size applications logs grow enormously fast, it’s a pity Rails doesn’t provide built-in functionality for that like Apache web-server does. Fortunately there is an easy and fast solution for that issue.
1. Install cronolog
“cronolog [http://cronolog.org/] is a simple filter program that reads log file entries from standard input and writes each entry to the output file specified by a filename template and the current date and time.”
For details, and list of parameters see: [http://cronolog.org/usage.html]
On GNU/Linux Debian:
# apt-get install cronolog
2. Setup your Rails application
Edit necessary environment file: like ‘config/environments/production.rb’ file
1 2 3 4 5 | # system logger configuration # config.logger = SyslogLogger.new config.logger = Logger.new(IO.popen("FULL_PATH_TO_CRONOLOG log/production.log.%Y%m%d", "w")) config.logger.level = Logger::INFO |
That’s all, fast and easy .. Enjoy!