On Mon, Oct 1, 2012 at 11:26 AM, Justin Collum <[email protected]> wrote:
> I can delete ./log (with recurse) and start my server up in production env > and I will have a production.log file there. But when I upload to heroku I > get the error log up above. I'm not sure what to do next. Suggestions? > Don't use the filesystem for logs. As "The Twelve Factor App" (AKA The Heroku Bible) says, "A twelve-factor app never concerns itself with routing or storage of its output stream. It should not attempt to write to or manage logfiles." There are good reasons for this, most obviously that even if it "worked," you'd end up with either one file per dyno and a single visitor's requests scattered all over the place, or a dependence on a network filesystem, a ton more platform complexity to magically present it, and a prayer that concurrent writes don't trample one another. When running on Heroku, event streams become the platform's problem. The app's job is to write them to stdout. Heroku does that for most Ruby apps by injecting rails_log_stdout <https://github.com/ddollar/rails_log_stdout> during deployment. Instantiating a new Logger instance probably works around it. (Dynos do have access to a local filesystem, but it's destroyed when the dyno dies and is definitely not intended for logs.) The good news is that the fix is easy: remove that application.rb hack entirely and let rails_log_stdout do its thing. It works with a Rails 3 app without any changes. If you need to instantiate Logger for another reason, do it with Logger.new(STDOUT). That's rarely needed. Monitor logs with heroku logs, a log management add-on, and/or your own syslog drain. Since the platform is routing your logs, they can go to multiple places and can be rerouted independent of code changes or deploys. Speaking for my add-on, the result is a lot better than you'd get from a file per dyno or even a collated file, too -- long live logs, but not necessarily as log files :) Hope this helps, and please post more if unwinding your changes or using Logger.new(STDOUT) doesn't work. Troy -- papertrailapp.com -- making logs fun. ish. -- You received this message because you are subscribed to the Google Groups "Heroku" group. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/heroku?hl=en_US?hl=en
