Search code examples
loggingherokupadrino

How do I enable logging for a Padrino app on Heroku?


Help me out here; I must be missing something really obvious.

I have a Padrino app running on Heroku. In boot.rb, in the block passed to Padrino.before_load, I have the following lines:

Padrino::Logger::Config[:production][:log_level] = :info
Padrino::Logger::Config[:production][:stream] = :stdout

And in the before block in app.rb, I have calls to logger.info scattered throughout.

This logs to standard out just fine on my development machine. But when I check my Heroku logs:

heroku logs -t -s app

...I don't see anything (just the initial 3 lines of startup info from the Thin server).

What am I missing?


Some points of clarification in response to culix:

  1. Switching to heroku logs -s app after the app starts does not change anything for me.
  2. I tried installing Papertrail. Which actually looks quite nice! But it still doesn't have the log messages I'm looking for.
  3. That is a good question! I really did just have calls to logger.info in the before block. I will add more logging and check back, after I finish updating this question.
  4. Now that you ask: my app doesn't seem to be logging anything either when I switch to running in "production" (after changing database.rb to just point to the development DB). I think this means I'm just fundamentally configuring Padrino logging incorrectly. Thanks for asking this question!
  5. Latest boot.rb is committed.
  6. Nope—not (intentionally) messing with stdout in any way.

Obviously the first thing I should spend time investigating is #4 above; that's what I will do now. Then, in case it yields nothing, on to #3.


Solution

  • Here are some simple questions just to make sure we've covered the basics:

    1. Are you running heroku logs -t before or after your app starts? If you're not running that until afterward does dropping the -t switch and running heroku logs -s app display anything?

    2. Do you have any syslog drain addons added to your app? If so do they display anything? If not, try adding one and running your app again - do any log details show up in the drain?

    3. After deploying to heroku, if you visit your app's website and exercise your app's pages, does output from any other activity show up in the logs or syslog drain? i.e. are you able to confirm whether this is an issue with all logging for your app when running on heroku's servers vs only an issue logging things in the before section?

    4. When running on your local machine does your app still log to :production, or does it log somewhere else? i.e. is your app doing the same thing locally as when it runs on a heroku machine? Did your deployed app somehow get set to run as a different Padrino logging environment?

    5. Is the latest version of your boot.rb file committed to the git repo that you're pushing to heroku? If you execute heroku run ls on the appropriate directory can you see the file on a heroku web dyno?

    6. As a last resort, you're not doing anything that messes with stdout, redirects output or print statements to somewhere else, or anything or the sort are you?