Reputation: 332
I'm having a huge rails application log. is it normal ?' 768 megs for the production log !!
root@demo3:/home/canvas/canvas/log# ls -lh
total 960M
-rw-r--r-- 1 canvas canvas 192M Sep 28 12:37 delayed_job.log
-rw-rw-r-- 1 canvas canvas 265 Sep 22 08:57 development.log
-rw-r--r-- 1 canvas canvas 910K Sep 28 12:36 newrelic_agent.log
-rw-r--r-- 1 canvas canvas 768M Sep 28 12:37 production.log
-rw-r--r-- 1 root root 26K Sep 28 11:00 super_delayed_job_err.log
-rw-r--r-- 1 root root 113K Sep 22 14:07 super_delayed_job.log
Snippet from the log file: [- 1e1f92f0-293e-0132-2906-00163c067c2e] Cache hit: _account_lookup2/1 ({}) [- 1e1f92f0-293e-0132-2906-00163c067c2e] Cache hit: settings_for_plugin2/sessions ({}) [- 208bd370-293e-0132-2906-00163c067c2e]
Processing UsersController#user_dashboard (for 54.248.250.232 at 2014-09-28 14:06:04) [GET]
[- 208bd370-293e-0132-2906-00163c067c2e] Parameters: {"controller"=>"users", "action"=>"user_dashboard"}
[- 208bd370-293e-0132-2906-00163c067c2e] Redirected to http://subdomain.example.com/login
[- 208bd370-293e-0132-2906-00163c067c2e] Filter chain halted as [:require_user] rendered_or_redirected.
[- 208bd370-293e-0132-2906-00163c067c2e] Completed in 3ms (DB: 0) | 302 Found [http://demo3.iqraalms.com/]
[- 208bd370-293e-0132-2906-00163c067c2e] [STAT] 903612 903612 0 903612 0.010000000000000231 0
Any idea how to optimise it ?
Upvotes: 0
Views: 85
Reputation: 171
You could raise the log level to get less data (warn, error or fatal) in your config file as described in rails guide on debugging. Or as sjaime pointed out in his comment, logrotate is a utility that will solve this problem for you (compress your log every day/week/month or when it reaches a certain size, delete/email/keep old archives, ...).
One thing that will blow up your log tremendously are for example asset errors (missing fonts is a classic there). Make sure you have non of these. Other than that, with log level info and a couple of users on your site, your log will grow quickly.
Upvotes: 1