"puts" output not displaying in Heroku logs for Sinatra app
Asked Answered
E

1

21

I'm trying to use "puts" to test a few things with a Sinatra app that's hosted on Heroku. Interestingly, the output seems to queue up and only displays upon restarting the Heroku dyno. I've tried with 'Thin' and 'Webrick', but have the same issue.

Any thoughts?

Exsanguine answered 7/3, 2014 at 22:7 Comment(3)
It does work on Heroku. Are you using Heroku's log monitor?Anallese
Using Heroku logs, yes. That's how I can see the output upon restarting the dyno.Exsanguine
You might just need to sync stdout. Try adding $stdout.sync = true early in your apps startup (top of config.ru is a good place).Aglet
T
38

As you can see on heroku docs: add this to your config.ru:

$stdout.sync = true

Don't forget the $ before stdout or it won't work.

Trod answered 20/8, 2014 at 7:14 Comment(1)
Thank you! I missed this in the docs and couldn't work out why I wasn't seeing my logs.Schoolbook

© 2022 - 2024 — McMap. All rights reserved.