如何查看Rails开发日志?

发布于 2024-07-24 22:02:19 字数 348 浏览 4 评论 0原文

我的团队成员正在 Windows XP 上开发 Rails 应用程序。 我们发现,当我们运行该应用程序时,无论是在 NetBeans 中启动它还是通过打开控制台并调用 script/server,Rails 开发日志都不会滚动。 只有 Webrick 启动消息。 该应用程序肯定正在运行,但是当我们在浏览器中点击各个页面时,我们没有看到任何日志输出。

当我在 OS X 系统上查看相同的应用程序时,日志输出按预期工作。

我确实确保它在 Rails“开发”环境中运行。

有什么想法为什么日志记录会被抑制吗?

environment.rb 文件的配置参数是否会影响它?

A member of my team is developing a Rails app on Windows XP. We are finding that when we run the app, either launching it within NetBeans or by opening a console and calling script/server, the Rails development log does not scroll by. There is only the Webrick startup message. The app is definitely running, but when we hit various pages in the browser we aren't seeing any logging output.

When I look at the identical app on my OS X system, logging output works as expected.

I did make sure that it's running in Rails "development" environment.

Any ideas why logging would be suppressed?

Are there config params for the environment.rb file that would affect it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

杀手六號 2024-07-31 22:02:19

查看 log/ 目录 - 应该有一个 development.log。 我打赌你的输出就在那里。

如果不是,请确保该目录可写。

有关如何在运行时查看它:如果您安装了 git bash 或其他一些 shell(例如 cygwin),那么您可以打开一个 shell 并执行 tail -f log/development.log当日志被附加内容时会滚动日志。

Look in the log/ directory - there should be a development.log. I bet your output is there.

If it's not, make sure that directory is writable.

For how to see it while you're running: if you have git bash installed, or some other shell such as cygwin, then you can open a shell and do tail -f log/development.log which will scroll the log as it gets stuff appended to it.

迷路的信 2024-07-31 22:02:19

Rails Configuration 文档建议您可能有 log_level在配置中设置为 :debug 以外的内容。

还有一个查看请求的替代位置:Rails 应用程序中的 log/development.log 文件。 如果那里什么也没写,那么你的问题一定出在配置上。 在 *nix 系统上,我将运行:

$ tail -f log/development.log

并观察运行的请求。 他们告诉我有一个Windows 版本的tail

The Rails Configuration documentation suggests that you may have log_level set to something other than :debug in your configuration.

There is also an alternative place to view the requests: the log/development.log file in your Rails app. If nothing is written there, then your problem must be in configuration. On a *nix system I would run:

$ tail -f log/development.log

And watch the requests run by. They tell me that there is a Windows version of tail.

左岸枫 2024-07-31 22:02:19
less -R log/development.log

我刚刚开始使用这个。

less -R log/development.log

I just started to use this.

半葬歌 2024-07-31 22:02:19

您可以使用以下命令查看运行时日志:

tail -f log/development.log

此外,如果您只想要日志中的第一行或最后一行,您可以使用以下命令获取这些行(日志中的第一行/最后 100 行):

例如:

前 100 行:

head -n 100 log/development.log 

最后 100 行:

tail -n 100 log/development.log

谢谢!

You can see the run-time logs using the below command:

tail -f log/development.log

Also if you just want first or last number of lines from the logs you can just get those using below command (first / last 100 lines from logs):

For example:

First 100 lines:

head -n 100 log/development.log 

Last 100 lines:

tail -n 100 log/development.log

Thanks!

零崎曲识 2024-07-31 22:02:19

我总是使用 log/development.log 查看日志。 只需使用 cygwin 或其他东西来 tail -f 即可。

也许您的 Windows 环境正在使用 WEBrick,而 OS X 环境正在使用 Mongrel 或其他网络服务器。 我注意到,对于某些网络服务器,日志记录输出(也)直接写入外壳,而其他网络服务器仅写入日志文件。

I always use log/development.log to look at the logs. Just tail -f it using cygwin or something.

Maybe your Windows environment is using WEBrick and the OS X environment is using Mongrel or other webserver. I've noticed that with some webservers the logging output is (also) written directly into the shell and with others is written only to the log files.

2024-07-31 22:02:19

试试这个,获取开发日志:

tail -f log/development.log

确保您位于应用程序路径中。

Try this, to get development log:

tail -f log/development.log

Make sure that you are in the application path.

空袭的梦i 2024-07-31 22:02:19

当开发日志变得太大时,Netbeans 似乎停止在控制台窗口中显示开发日志。 至少那是我的经历。

Netbeans seems to stop displaying the dev log in the console window when the dev log gets too large. At least that was my experience.

南巷近海 2024-07-31 22:02:19

如果不深入研究 Webrick 的源代码,我怀疑默认显示的信息量并不大。 您确定您在 OSX 上运行 Webrick 而不是 Mongrel 吗?

事实上,继续使用 Webrick 是否有特殊原因? 在 Phusion Passenger 出现之前,Mongrel 已成为事实上首选的前端服务器,并且它在 Windows 上运行得很好。 如果您安装了它(gem install mongrel),那么 Rails 将默认使用它。

在我的开发环境中,运行 Webrick(在我弄清楚如何运行之后 - 已经很长时间了)我得到了非常简短的输出:只是“GET”请求的记录。 切换到 Mongrel,我得到了完整的作品:请求、参数、SQL、计时等。

Without digging into the source for Webrick, I suspect that the amount of information displayed is by default not large. Are you sure you're running Webrick on OSX and not Mongrel?

In fact, is there a particular reason for continuing to use Webrick at all? Before the advent of Phusion Passenger, Mongrel had become the de facto front-end server of choice, and it works just fine on Windows. If you install it (gem install mongrel) then Rails will use it by default.

In my development environment, running Webrick (after I'd figured out how - it's been a long time) I got very brief output: just a record of the "GET" request. Switching to Mongrel, I got the full works: request, parameters, SQL, timings etc.

软糖 2024-07-31 22:02:19

我将 tail 与 grep 一起使用,

tail -f log/development.log | grep Started -A 1

效果很好。

I use tail with grep

tail -f log/development.log | grep Started -A 1

Works beautifully.

活泼老夫 2024-07-31 22:02:19

你可以尝试这个命令

$ tail -f development.log


$ tail -f log/development.log

You can try this command

$ tail -f development.log


$ tail -f log/development.log
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文