简体   繁体   English

Rails WEBrick不写日志到终端(stdout)

[英]Rails WEBrick not writing log to terminal (stdout)

WEBrick usually writes its output to both development.log and stdout. WEBrick通常将其输出写入development.log和stdout。 However it suddenly stopped doing so and it is not writing to stdout. 然而,它突然停止这样做,它没有写入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. development.log似乎写得正确。

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. 另一方面,如果我创建另一个Rails项目(并复制Gemfile和Gemfile.lock以确保我拥有相同的gems),我会在终端上获得正常输出。

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. 这是一个很大的问题,因为它阻止我们使用pry或ruby-debug,因为我无法访问断点上的进程。

We're using Ruby ruby-1.9.3-p194, Rails 3.2.8 and WEBrick 1.3.1. 我们使用Ruby ruby​​-1.9.3-p194,Rails 3.2.8和WEBrick 1.3.1。 In case it matters we're all on Macs (Mountain Lion). 如果重要的话我们都在Macs(Mountain Lion)上。

Any ideas what could be causing this and how to solve it? 什么可能导致这个以及如何解决它? We need stdout back! 我们需要stdout回来! Thanks 谢谢

It turned out that someone had added these three lines to config.ru 原来,有人将这三行添加到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. 弄清楚这个是非常痛苦的,所以不用说,不要这样做。

如果你使用pry-remote你应该没问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM