运行rails后无法生成日志

问题描述 投票:0回答:2

运行 Rails 后,我无法在终端上看到日志,代码可以正常工作,没有任何问题。日志正在生成日志/development.log 文件由于没有日志我无法使用调试器

=> Booting Puma
=> Rails 5.2.3 application starting in development 
=> Run `rails server -h` for more startup options
[95163] Puma starting in cluster mode...
[95163] * Version 4.1.1 (ruby 2.4.6-p354), codename: Fourth and One
[95163] * Min threads: 2, max threads: 2
[95163] * Environment: development
[95163] * Process workers: 2
[95163] * Phased restart available
[95163] * Listening on tcp://localhost:3000
[95163] Use Ctrl-C to stop

config/dvelopment.log 文件

Rails.application.configure do
 
 
  config.active_storage.service = :local


  config.action_mailer.perform_caching = false
          
  config.assets.debug = true

  config.assets.quiet = true

  config.assets.raise_runtime_errors = true

  config.action_mailer.default_url_options = {
    host: Rails.application.secrets[:mailer_options][:host],
    port: Rails.application.secrets[:mailer_options][:port],
  }

  # ActiveRecord::Base.logger = ActiveSupport::Logger.new(STDOUT)

  config.lograge.enabled = true
  config.log_level = :debug
  config.lograge.formatter = Lograge::Formatters::Logstash.new

  config.lograge.custom_options = lambda do |event|
    {
      :time => Time.now.in_time_zone(Time.zone),
      :params => event.payload[:params].reject { |k| %w(controller action).include? k },
      :subdomain => event.payload[:subdomain],
      :remote_ip => event.payload[:remote_ip],
      :user_agent => event.payload[:user_agent],
      :uuid => event.payload[:uuid],
      :current_user => (event.payload[:current_user])? event.payload[:current_user][:id] : nil,
      :current_appuser => (event.payload[:current_appuser])? event.payload[:current_appuser][:id] : nil
    }
  end
  config.lograge.ignore_actions = ['PublicPagesController#status_check']

  config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 7, 204857600)

     require "awesome_print"
end
ruby-on-rails ruby puma
2个回答
1
投票

当您想要在

STDOUT
环境中登录到
development
而不是日志文件时,请在
config/environments/development.rb

中更改此行
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 7, 204857600)

config.logger = Logger.new(STDOUT)

0
投票

在单一模式下运行 Puma,它将恢复日志。

您必须在 Puma 配置文件中设置

workers 0
或删除该行。

它看到你的已设置为

workers 2

© www.soinside.com 2019 - 2024. All rights reserved.