No hay mensajes de registro en production.log

I wrote a demo HelloWorld Rails app and tested it with WEBrick (it doesn't even use a DB, it's just a controller which prints "hello world"). Then I tried to deploy it to a local Apache powered with Passenger. In fact this test is just to get Passenger working (it's my first deploy on Apache). Now I'm not even sure that Passenger works, but I don't get any error on the Apache side.

When I fire http://rails.test/ the browser shows the Rails 500 error page - so I assume that Passenger works. I want to investigate the logs, but it happens that production.log is empty! I don't think it's a permission problem, because if I delete the file, it is recreated when I reload the page. I tried to change the log level in conf/environments/production.rb, tried to manually write to log file with Rails console production and


vuelve true but nothing gets written to production.log. The path (obtained per Rails.logger.inspect) is correct, and I remark that the file is recreated if I manually remove it. How can I know what's going on?

(I already checked the Apache logs, plus I set the highest debug level for Passenger but it seems a Rails problem, so is not logged by the server)

preguntado el 09 de marzo de 12 a las 14:03

I'm still having this problem, even though i'm in rails 4....what did you end up doing? -

Just upgraded Rails. It might be a regression -

2 Respuestas

Assuming you're running Rails 3.2.1, this is a bug. It was patched in 3.2.2.

If you can't upgrade to 3.2.2 for any reason, this comment on GitHub has a workaround:

# config/initializers/patch_rails_production_logging.rb
Rails.logger.instance_variable_get(:@logger).instance_variable_get(:@log_dest).sync = true if Rails.logger

respondido 09 mar '12, 15:03

The strange thing is that I played with Logger.flush in the Rails console, but it didn't have any effect. Upgrading solved my issue - Raffaele

Glad that helped. I updated the answer with a workaround for anyone who can't upgrade. - Brandan

undefined method 'sync=' for nil:NilClass (NoMethodError) with rails 4.1.2 - RAJ

You shouldn't need this in Rails 4. This was fixed in Rails 3.2.2, and this answer is just a workaround for people on Rails 3.2.1. - Brandan

Setting this works on Rails 3.2.11:

Rails.logger ="log","production.log"))

Respondido el 17 de diciembre de 18 a las 20:12

hi - where do i add this line? - indefinido

I put this into an initializer under config. for example, in config/initializers/logger.rb: if !Rails.env.development? Rails.logger ="log","#{Rails.env}.log")) end Seriously, how do I get a newline without cut-pasting in a newline? If I hit the enter key is saves my edit. - Mike P.

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.