Rails not writing to production logs

June 20, 2014 11.8k views
I followed the tutorial (https://www.digitalocean.com/community/articles/how-to-use-the-dokku-one-click-digitalocean-image-to-run-a-ruby-on-rails-app) to get my rails app up and running with dokku. When I do: dokku logs APP_NAME, all that I see are three lines corresponding to the server starting, so my logs aren't being written to properly. How can I debug this? Common reasons my app isn't writing production logs? Thanks
1 comment
4 Answers
Do you have any logging related values set in config/environments/production.rb ? The default should be:
config.log_level = :info
RAILS_DEFAULT_LOGGER = Logger.new('log/production.log')
Make sure you haven't used SyslogLogger as that will log to the OS syslog, not a separate Rails app log, and Dokku won't find it. If you need to dig around in the container itself to debug and make sure the log is actually being created, you can run:
 dokku run app_name '/bin/bash'
  • I have the two lines in production.rb you specify. When I do: dokku run app_name '/bin/bash' the production.log is indeed empty. Only line is: # Logfile created on 2014-06-20 17:34:50 +0000 by logger.rb/41954 Permissions for the file production.log are: -rw-r--r--r 1 root root 66 Jun 20 17:34 production.log Those look good as well. Any other thoughts on what may be wrong?
  • Appears there may be bigger problems: dokku run app_name rails c results in: stat /exec: no such file or directory These two issues are related?
Okay I fixed the rails c problem, but the logs debacle still remains unfortunately. Do you know of any other alternatives for generating logs I can use in the meantime?

Has anyone found a solution to this problem? I'm having the exact same issue.

Try doing docker ps to get a list of your containers. Find your container under the container ID column. After that do docker logs <container-id>.

Have another answer? Share your knowledge.