【问题标题】:View Rails database log in development开发中查看 Rails 数据库日志
【发布时间】:2015-05-27 07:45:24
【问题描述】:

我可以通过在我的开发机器上运行 heroku logs -p postgres -t 在 Heroku 上查看我的生产数据库日志。如何对我的开发数据库执行此操作?

只是尝试调试一些跳过 Rails 并直接进入数据库的 rails 命令。

【问题讨论】:

    标签: ruby-on-rails postgresql heroku


    【解决方案1】:

    您必须启用 PostgreSQL 执行的所有 SQL 的日志记录

    在您的 data/postgresql.conf 文件中,将 log_statement 设置更改为 'all'

    Error Reporting and Logging - log_statement

    tail -f fil_path 将显示文件的运行时更新,因此您可以借助它进行检查

    tail -f /usr/local/var/postgres/server.log
    

    【讨论】:

      【解决方案2】:

      假设您使用的是 Mac 并且您通过 Homebrew 安装了 Postgres,您可以通过运行以下命令在您的开发机器上实时查看本地 Postgres 日志:

      tail -f /usr/local/var/postgres/server.log
      

      【讨论】:

      • 谢谢。我也在使用 PGAdminIII (3) 运行 Ubuntu,因此它位于我的 /home/username/pgadmin.log'. I also had to change the postgresql.conf file as per user3118220 comments below. And also ran SHOW config_file;` 作为 SQL 命令来查找我的 postgresql.conf 文件的位置。祝大家欢呼。 stackoverflow.com/questions/3602450/…
      猜你喜欢
      • 2010-11-04
      • 2012-11-14
      • 2011-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-04
      • 1970-01-01
      • 2010-11-04
      相关资源
      最近更新 更多