Search code examples
ruby-on-railswebrick

Rails WEBrick not writing log to terminal (stdout)


WEBrick usually writes its output to both development.log and stdout. However it suddenly stopped doing so and it is not writing to stdout. All we're getting is

Booting WEBrick
=> Rails 3.2.8 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

and then nothing. development.log seems to be written to properly.

This is a project-specific problem because it's happening to all members of our team in different computers. On the other hand if I create another Rails project (and copy the Gemfile and Gemfile.lock to ensure I have the same gems) I get the normal output on the terminal.

This is a big problem because among other things it prevents us from using pry or ruby-debug since I have no access to the process on a breakpoint.

We're using Ruby ruby-1.9.3-p194, Rails 3.2.8 and WEBrick 1.3.1. In case it matters we're all on Macs (Mountain Lion).

Any ideas what could be causing this and how to solve it? We need stdout back! Thanks


Solution

  • It turned out that someone had added these three lines to config.ru

    log = File.new("console.log", "a+")
    $stdout.reopen(log)
    $stderr.reopen(log)
    

    It was very painful to figure out this one, so needless to say, don't do that.