【问题标题】:Can you supress asset messages when tailing the development.log?您可以在跟踪 development.log 时抑制资产消息吗?
【发布时间】:2011-10-13 12:17:01
【问题描述】:

在开发 Ruby on Rails 应用程序期间,我通过tail -f log/development.log 不断跟踪开发日志。

我几周前才开始在 Rails 中进行开发,所以我不知道日志是否一直显示这么多条目,但我相信资产最近才在 3.1 中添加。不管怎样,这是我的development.log 的一个页面调用的摘录:

Started GET "/assets/reset.css?body=1" for 70.63.17.68 at Wed Oct 12 20:10:49 +0000 2011
Served asset /reset.css - 304 Not Modified (1ms)


Started GET "/assets/style.css?body=1" for 70.63.17.68 at Wed Oct 12 20:10:49 +0000 2011
Served asset /style.css - 304 Not Modified (0ms)


Started GET "/assets/application.css?body=1" for 70.63.17.68 at Wed Oct 12 20:10:49 +0000 2011
Started asset /application.css - 304 Not Modified (0ms)


Started GET "/assets/application.js?body=1" for 70.63.17.68 at Wed Oct 12 20:10:49 +0000 2011
Served asset /application.js - 200 OK (1ms)

实际上还有一些条目,但我认为您已经看到这占用了大量空间,每个 GET 请求之间的所有新行都占用了很多空间。我还删除了 Rails 在使用 generate 时创建的所有未使用的 scss 和咖啡文件。

我只想在tail development.log 中查看所有数据库调用和实际页面调用。

我想知道是否有人知道阻止 Rails 记录这些事件的方法,或者是否有 | grep 排除与资产相关的所有内容的方法。

非常感谢您的帮助,谢谢。

【问题讨论】:

    标签: ruby-on-rails logging grep tail


    【解决方案1】:

    在您的config/environments/development.rb 集合中

    config.assets.debug = false

    【讨论】:

    • 显然它必须提供帮助,但我仍然在 2012 年 4 月 9 日星期一 00:16:01 +0300 为 127.0.0.1 开始获取“/assets/application.js” 服务资产/应用程序。 js - 304 Not Modified (200ms) 有什么问题? (我已经重启了两次服务器)
    • 当调试模式关闭时,sprockets 会连接资产文件,因此您只会收到 application.jsapplication.css 的日志消息,而不是资产目录中的所有文件。
    猜你喜欢
    • 1970-01-01
    • 2014-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-04
    • 2020-06-16
    相关资源
    最近更新 更多