Tyler DeWitt
Tyler DeWitt

Reputation: 23576

Rails logging in Production Environment

What kind of information should I expect to see in production.log from a default production environment in rails 3.2?

I'm running Passenger and have tried accessing made up controller names and invalid parameters, but nothing is showing up in production.log.

I tried setting the logger level to debug in environments/production.rb, but that log is still blank.

Thanks

Edit

Here's more info on the flushing issue:

https://github.com/rails/rails/issues/4277

Upvotes: 1

Views: 4984

Answers (2)

Rajan Verma - Aarvy
Rajan Verma - Aarvy

Reputation: 2117

You might need to set Rails.logger to ActiveSupport::Logger by creating an initializer.

Check the value by Rails.logger if it shows <RailsStdoutLogging::StdoutLogger: change it to active support.

config/initializer/logger.rb 

Rails.logger = ActiveSupport::Logger.new('log/production.log')

EDIT: I tried doing the same in production.rb using config.logger but it always gets overwritten. So i decided to go with this approach.

Upvotes: 2

Mikhail Cheshkov
Mikhail Cheshkov

Reputation: 226

Seems like it's because of logfile flushing. By default rails not flushing every write to log in production environment.

This pull request fix it, and in rails HEAD you can try

config.autoflush_log = true

Upvotes: 2

Related Questions