首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >运行rails后无法生成日志。

运行rails后无法生成日志。
EN

Stack Overflow用户
提问于 2022-10-24 09:53:17
回答 1查看 43关注 0票数 -1

在运行rails之后,我看不到终端上的日志,代码运行正常,没有任何问题。这些日志正在生成日志/Development.log文件,因为没有无法使用调试器的日志。

代码语言:javascript
运行
复制
=> 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/ddevment.log文件

代码语言:javascript
运行
复制
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
EN

回答 1

Stack Overflow用户

发布于 2022-10-24 15:16:41

当您想在STDOUT环境中而不是在日志文件中登录到development时,请在config/environments/development.rb中更改这一行

代码语言:javascript
运行
复制
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 7, 204857600)

代码语言:javascript
运行
复制
config.logger = Logger.new(STDOUT)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74179384

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档