【问题标题】:running rails app in production mode is not displaying the production server logs in terminal. and showing the error something went wrong in browser在生产模式下运行 rails app 不会在终端中显示生产服务器日志。并显示错误浏览器出现问题
【发布时间】:2015-07-30 06:12:30
【问题描述】:

当我在开发模式下运行 rails 应用程序时,服务器日志正确显示在终端中。但是当我在生产模式下运行应用程序时,服务器没有在终端中显示任何服务器日志。并且浏览器中显示错误,例如“我们很抱歉,但出了点问题。”。我正在使用以下命令运行服务器。我正在使用瘦服务器。

rails s -e production

这是我在启动服务器时在服务器模式下获得的输出。之后,当我发出任何请求时,没有显示输出。

prashant@prashant-pc:~/client_proj/template$ rails s -e production
=> Booting Thin
=> Rails 4.1.5 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
[DEPRECATION] requiring "RMagick" is deprecated. Use "rmagick" instead
Thin web server (v1.6.3 codename Protein Powder)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop

我没有得到什么问题。

【问题讨论】:

  • production.rbconfig.log_level 设置为什么?
  • config.log_level = :info
  • 一旦尝试将其设置为:debug 不确定它是否会有所帮助,试一试。然后重新启动服务器并进行测试。
  • 我试过但没用。仍然存在同样的问题。
  • 请检查是否有必要的权限在production.log文件上创建和写入

标签: ruby-on-rails console server development-environment production


【解决方案1】:

production.rb 你可以添加这个选项: config.logger = Logger.new(STDOUT)

【讨论】:

    【解决方案2】:

    如果你在production.rb看到这个块

      if ENV["RAILS_LOG_TO_STDOUT"].present?
        logger           = ActiveSupport::Logger.new(STDOUT)
        logger.formatter = config.log_formatter
        config.logger    = ActiveSupport::TaggedLogging.new(logger)
      end
    

    然后您可以在启动rails server 之前使用export 简单地将环境变量设置为任何值

    $ export RAILS_LOG_TO_STDOUT=true
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-07
      • 2011-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多