I've created a new environment file in my Rails 4 app (config/environments/staging.rb). The settings in this file are exactly those found in the default development.rb file created when the app was generated.
When firing up WEBrick in the console using this environment (rails s -e staging or RAILS_ENV=staging rails s), I don't see anything written to STDOUT. I can see the log file for the staging environment being written to, but nothing in STDOUT. I understand I can tail the file, but I was wondering if there was a config setting to handle this. I can also redirect the Rails logger to output everything to STDOUT, but how can I get my custom environment to write to both STDOUT and the log file?
I can replicate this on both OSX and Windows with a new Rails 4 app, and the default environments work as expected.
Figured it out. Modify your environment config file to use the Rails::Rack::LogTailer middleware:
# config/environments/staging.rb
Rails.application.configure do
config.middleware.insert_before(Rails::Rack::Logger, Rails::Rack::LogTailer)
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With