Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the log location (i.e., `LogDevice`) in a Ruby on Rails (version 6) application

Tags:

Rails 3 seems to have had a property in config for changing the output location of Rails.logger, config.log_path. That's been deprecated. Looking at a Rails 6 application, is this the way to do that now? Or did this config property get moved to something new?

  logger           = ActiveSupport::Logger.new('log/blahblah.log')
  logger.formatter = config.log_formatter
  config.logger    = ActiveSupport::TaggedLogging.new(logger)
like image 840
cdmo Avatar asked Aug 17 '20 13:08

cdmo


People also ask

Where are logs stored in rails?

In a Rails app, logs are stored under the /log folder. In development mode, the development. log file is used & you see log output on the terminal you're running rails server on.

How do I use logger in Ruby on rails?

To write in the current log use the logger. (debug|info|warn|error|fatal|unknown) method from within a controller, model, or mailer: logger. debug "Person attributes hash: #{@person.

What is log file in rails?

log file. Rails uses six different log levels: debug, info, warn, error, fatal, and unknown. Each level defines how much information your application will log: Debug: diagnostic information for developers and system administrators, including database calls or inspecting object attributes.

What is logger in ruby?

Logger is a simple but powerful logging utility to output messages in your Ruby program. Logger has the following features: Print messages to different levels such as info and error. Auto-rolling of log files. Setting the format of log messages.


1 Answers

This will do the trick:

config.paths['log'] = 'log/new_log_file.log'

You can read more about paths here: https://api.rubyonrails.org/classes/Rails/Application/Configuration.html#method-i-paths

like image 68
nuaky Avatar answered Sep 30 '22 19:09

nuaky