3

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.

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.