Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Make compatible with Heroku by adding logs to both Mongo and STDOUT #11

wants to merge 4 commits into


None yet
6 participants

reedlaw commented May 3, 2011

Heroku logs require messages to be sent to STDOUT. This patch makes central_logger store logs both in mongodb and output to STDOUT.

Thanks, this was helpful. I'm a little surprised there's not more noise about this, I would guess logging is broken for anyone using central logger and heroku without these patches.

You should indent touch to the same level as mkdir.


reedlaw replied May 31, 2011

Good call, didn't see that in my editor.


astupka commented Jul 21, 2011

Took a while to get around to this, but thanks for the pull request.

I don't believe writing to STDOUT is necessary to see your logs. Wouldn't it be desirable to use the existing channels to see your app log? Let me know if I'm missing something here.

Somewhere in app
logger.info "All your base are belong to us."

Will show your log statement
heroku logs --source app


The requirement to write to STDOUT is written in the link you provided...


reedlaw commented Jul 21, 2011

I needed this back when I was on Heroku. Now I no longer need it, but a number of people have found it useful.


astupka commented Jul 21, 2011

@reedlaw Were you using rails? The mongo logger still logs to the app log, which should be viewable using

heroku logs --source app

@betelgeuse Logging to STDOUT is not required to see your app logs. The central logger extends BufferedLogger, which still writes to the production log file. That is viewable using the above command. Is there some other use case I should be supporting?

reedlaw commented Jul 21, 2011

Yes, I patched central_logger because Heroku support told me that in order for their advanced logging to work the app must output all logs to STDOUT.

@astupka I think Heroku with the new logging system does not use the production log file any more. I haven't tested verbatim central_logger on Heroku recently but I think I subscribed here because I needed the patches to get it working.

slim2000 commented Aug 1, 2011

Yes.... still critical to do the following for Heroku as pointed out in redlaw's 808e05f patch :

mkdir vendor/plugins/rails_log_stdout
touch vendor/plugins/rails_log_stdout/.gitkeep

had been working on this issue for a few hours until I tried this... worked right away.

thanks you reedlaw!

turadg commented Sep 8, 2011

Central Logger stopped working for me on Heroku about a month ago. I was tearing my hair out until finding this patch from @reedlaw. @astupka, what do you need to merge this pull request? I can make a fresh commit and request if you want.

In the meantime, here's a fork with some of the recent pull requests: https://github.com/turadg/central_logger/commits/master

turadg commented Sep 10, 2011

Update: the vendor/plugins trick was working for me then stopped yesterday. I wrote Heroku support to ask how to stop the injection of their rails_log_stdout and they replied:

There is no way to avoid injection of this plugin on Cedar; however,
you can bypass this by re-setting the logger after plugins are loaded,
or explicitly declaring the list of plugins (config.plugins = ...) you
wish to install to not include this plugin. Note that this may break
any other plugins we automatically inject in the future (e.g. our
rails 3.1 runtime asset compilation plugin) so you should be aware of
this going forward.

Can a feature be added to Central Logger to detect when the logger is borked and reset it accordingly?

turadg commented Sep 10, 2011

Update: what I thought was central_logger no longer working (due to the error messages) was just confined to rake assets:precompile. As describe in Rails 3.1 on Heroku Cedar, the env config vars aren't available in this process. I'm getting messages like PGError: could not connect to server. I believe this is triggered by Central Logger being unable to connect:

       CentralLogger Initializer Error: Unable to access log file. Please ensure that /tmp/build_10dle9td5yslt/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.

…because I keep my Central Logger password in a config var for security (rather than in source). I don't really need central_logger activated during assets:precompile. Can CL be silenced when in a rake task?

I hope these comments are relevant to other people trying to get Heroku and Central Logger working together. Btw, @jamescallmebrent has a commit to make these @reelaw's STDOUT logging happen only if ENV['HEROKU_RACK'].


astupka commented Dec 8, 2011

Late reply. Sorry. I am in the process of adding rails 3.1 support. I will release a new version of the gem in the next few weeks.

I need to add tests to this pull request to make sure it doesn't mess with non-heroku deploys.


turadg commented Nov 19, 2012

@astupka how's this one coming? :)

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