-1

After running the rails s i cannot see logs on the terminal the code is working properly without any issue. The logs are getting generated logs/development.log file As there are no logs i am unable to use debugger

=> 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 file

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
  • What does your logger configuration in `config/environments/development.rb` look like? Do I understand you correctly that you want to log to STDOUT instead of logging into a log file? – spickermann Oct 24 '22 at 10:02
  • Please post code, errors, sample data or textual output here as plain-text, not as images that can be hard to read, can’t be copy-pasted to help test code or use in answers, and are barrier to those who depend on screen readers or translation tools. You can edit your question to add the code in the body of your question. For easy formatting use the `{}` button to mark blocks of code, or indent with four spaces for the same effect. The contents of a **screenshot can’t be searched, run as code, or easily copied and edited to create a solution.** – tadman Oct 24 '22 at 11:55
  • What do you mean "the logs are getting generated", which implies the log is working, and "unable to generate logs" which implies the opposite? – tadman Oct 24 '22 at 11:56
  • It's not clear what do you mean by "As there are no logs i am unable to use debugger" - how logging to stdout and debugging are connected? – Konstantin Strukov Oct 24 '22 at 12:03
  • @KonstantinStrukov what i want to say is after running rails s we can see the log on terminal like what are the query being , file, api;s getting hit all those stuf does not appear on my terminal which makes debugging harder – Paarth Agrawal Oct 24 '22 at 12:50
  • @tadman i have removed the image thanks for improving me what i mean by logs are getting generated is that i can see the logs in logs/development.log file but i want then to appear on my terminal also – Paarth Agrawal Oct 24 '22 at 12:53
  • @spickermann i have added config/environments/development.rb file i want to see logs on terminal also – Paarth Agrawal Oct 24 '22 at 13:00
  • 1
    Your configuration clearly shows that you use lograge instead of logging to stdout (what is the commented line was responsible for). Either disable lograge in favor of stdout or simply call `tail -f ` in a separate console session and it will show you live logs almost like the default config does... – Konstantin Strukov Oct 24 '22 at 13:15

1 Answers1

1

When you want to log to STDOUT in development environment instead of into a log file, then change this line in your config/environments/development.rb

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

to

config.logger = Logger.new(STDOUT)
spickermann
  • 100,941
  • 9
  • 101
  • 131