![]() The way to fix this is to set the RACK_ENV environmental variable to none. This includes Rack::CommonLogger, which unsurprisingly logs all requests in the Apache common log format. In order to ease the transition from the rackup to unicorn commands, Unicorn adds the same default middleware as Rack to those two environments. ![]() This fixes the missing Rails logs, but what about Unicorn’s Apache-like output? This is a specific quirk of Unicorn for the development and deployment environments. ![]() Note: This workaround has been made obselete by the addition of the -no-default-middleware option to unicorn. If you want to use this trick to make Unicorn log to STDOUT in production, you can use the same code in production.rb, but change the default log level from 'DEBUG' to 'INFO' because that’s the standard behavior. The simplest way to fix this is to tell Rails to log to STDOUT instead: # config/environments/development.rb Hackerschool :: Application. Starting your app with unicorn does no such thing. When you start your app with rails server, a piece of middleware called Rails::Rack::LogTailer is loaded that prints the log to the screen after each request. Why is this happening? The Rails logger writes its logs to files, not STDOUT. Rails is still logging to log/development.log, but that’s not particularly useful. The standard Rails logs are no longer bing printed to STDOUT, and in their place is what looks like Apache access logs. Once Unicorn is running on your dev machine, you’ll find that the logs are quite different. Ours is pretty simple: # config/unicorn.rb if ENV = "development" worker_processes 1 else worker_processes 3 end timeout 30 The first step is to add Unicorn to your Gemfile and run bundle install: # Gemfile #. The information required to do this was scattered around the web, so I’ve collected it all in one place: To lower the risk of bugs popping up after pushing the site to production, I wanted to drop WEBrick in development and use Unicorn there as well. I’ve been doing some work on our servers and I decided to try using Unicorn. : Added note about -no-default-middleware.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |