Report this

What is the reason for this report?

Rails not writing to production logs

Posted on June 20, 2014

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



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

You have to redirect logs to Stdout, so edit config/environments/production.rb properly:

logger           = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger    = ActiveSupport::TaggedLogging.new(logger)

Hint: maybe you need the Lograge gem too.

Do you have any logging related values set in <code>config/environments/production.rb</code> ? The default should be: <pre> config.log_level = :info RAILS_DEFAULT_LOGGER = Logger.new(‘log/production.log’) </pre> Make sure you haven’t used <code>SyslogLogger</code> 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: <pre> dokku run app_name ‘/bin/bash’ </pre>

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?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.