CanCan breaks rails logger on Heroku #511

emiltin opened this Issue Nov 11, 2011 · 6 comments

5 participants


When cancan is installed on a rails 3 app deployed on Heroku's new cedar stack, calling logger.error(),, etc doesn't write anything to the log file.

I've been in touch with their support, and here what they say:

To make logging work we inject a plugin that redirects logger input to STDOUT.

Some gems interfere with that if they make changes to the default rails logger. I had some free time today, so I went ahead an debugged this. The two gems that are causing problems are 'cancan' and 'simple-navigation'.

There is a way to work around this if you want to keep those gems. You can disable the plugin by creating a vendor/plugins/rails_log_stdout dir in your application, and add a dummy file to it (like a .gitignore) so the directory will end up in git. This will stop this plugin being installed, so you can set the logger in production.rb to log to STDOUT yourself:

config.logger =
config.log_level = :info

Please let me know if this doesn't work for you.


Thanks for this. I tried your suggestion on our heroku app and it started logging everything again - although the log also included all the sql queries etc.

After a bit of googling, I found this thread:

After updating my production.rb with:
config.logger =
config.logger.level = Logger::INFO # use logger.level, not log_level

it started logging w/o the sql etc - much better. Turns out you dont need to disable the plugin by adding vendor/plugins/rails_log_stdout if you use the config settings above.

So - I think this is more of an heroku issue than cancan...


i agree. this is a heroku issue, and quite annoying that such a basic thing doesn't work well.


Hi guys,
If I put "config.logger =" this line in production.rb, I can get the following errors:

2012-01-02T10:11:34+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/rack/log_tailer.rb:8:in size': No such file or directory - log/production.log (Errno::ENOENT)
2012-01-02T10:11:34+00:00 app[web.2]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/rack/log_tailer.rb:8:in
2012-01-02T10:11:34+00:00 app[web.2]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.5/lib/rack/server.rb:295:in new'
2012-01-02T10:11:34+00:00 app[web.2]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.5/lib/rack/server.rb:295:in
block in build_app'
2012-01-02T10:11:34+00:00 app[web.2]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.5/lib/rack/server.rb:291:in reverse_each'
2012-01-02T10:11:34+00:00 app[web.2]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.5/lib/rack/server.rb:291:in
2012-01-02T10:11:34+00:00 app[web.2]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.5/lib/rack/server.rb:301:in wrapped_app'
2012-01-02T10:11:34+00:00 app[web.2]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.5/lib/rack/server.rb:252:in
2012-01-02T10:11:34+00:00 app[web.2]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/commands/server.rb:70:in start'
2012-01-02T10:11:34+00:00 app[web.2]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/commands.rb:54:in
block in '
2012-01-02T10:11:34+00:00 app[web.2]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/commands.rb:49:in tap'
2012-01-02T10:11:34+00:00 app[web.2]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/commands.rb:49:in
2012-01-02T10:11:34+00:00 app[web.2]: from script/rails:6:in require'
2012-01-02T10:11:34+00:00 app[web.2]: from script/rails:6:in

2012-01-02T10:11:36+00:00 heroku[web.2]: Process exited

I am clueless here. Any idea?


I was having this issue as well and adding

config.logger =
config.logger.level = Logger::INFO # use logger.level, not log_level

fixed my problem. I have not tried it but I imagine you could change it to respect the heroku environment variable as well by doing something like this:

config.logger.level = ENV['LOG_LEVEL'] ? Logger.class_eval(ENV['LOG_LEVEL']) : Logger::INFO

@heroku any chance you all could look into this particular issue and potentially update the rails_log_stdout plugin?


I was curious what CanCan would be doing to the Rails logger. I didn't find any references to Rails.logger or logger anywhere. In any event, this does sound like an issue with how Heroku handles logging rather than with CanCan. I'm going to close, but if there's disagreement let me know and we can re-open and discuss.

@derekprior derekprior closed this May 14, 2012

this is (was) a bug with heroku. simply adding the following lines to application.rb caused logging to stop working:

module MyModule
ActionController::Base.send(:include, MyModule)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment