【问题标题】:Debug Levels Rails - The level ":debug" show all logs. I want ONLY ERRORS. Is it possible?调试级别 Rails - 级别 ":debug" 显示所有日志。我只想要错误。可能吗?
【发布时间】:2016-06-01 01:43:01
【问题描述】:

我在 AWS Ec2 中有一个应用程序,我想在日志文件中查看错误(500、502、50x、403、404 等)。

文件config / environments / production.rb

有代码:

config.log_level = :debug

我尝试将其更改为:warn, :info, :error, :fatal。 实际上这个值只显示错误,但信息非常有限。

:debug 的值显示了许多数据,但是......也显示了所有日志......

我在这里看到错误日志:

EC2 ROOT: cd /var/log/nginx
CMD: tail -f error.log

应用程序内部还有另一个日志文件夹:

{appfolder}/current/log/production.log

但是这个文件是空的。此处未保存日志。

一些信息:

ruby -v: 2.2.2p95
rails -v: 4.2.1
OS: Ubuntu 14.04.2 LTS

谢谢大家。

【问题讨论】:

    标签: ruby ruby-on-rails-4 rails-4-2-1


    【解决方案1】:

    这里是the official documentation

    在您的 #config/environments/production.rb 中,您可以像这样添加/更改 log_level

      # Use the lowest log level to ensure availability of diagnostic information
      # when problems arise.
      # :debug, :info, :warn, :error, and :fatal
      config.log_level = :error
    

    希望对你有帮助

    快乐的黑客

    【讨论】:

      【解决方案2】:

      检查记录器类http://ruby-doc.org/stdlib-2.1.0/libdoc/logger/rdoc/Logger.html。只需使用适合您的日志级别即可。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-12-12
        • 1970-01-01
        • 1970-01-01
        • 2023-03-25
        • 2015-10-07
        • 2017-01-03
        • 1970-01-01
        相关资源
        最近更新 更多