Method deprecated or moved
This method is deprecated or moved on the latest stable version.
The last existing version (v2.3.8) is shown here.
initialize_logger()
public
If the RAILS_DEFAULT_LOGGER constant is already set, this initialization
routine does nothing. If the constant is not set, and Configuration#logger
is not nil, this also does nothing. Otherwise, a new logger instance is
created at Configuration#log_path, with a default log level of
Configuration#log_level.
If the log could not be created, the log will be set to output to
STDERR, with a log level of WARN.
Show source
def initialize_logger
return if Rails.logger
unless logger = configuration.logger
begin
logger = ActiveSupport::BufferedLogger.new(configuration.log_path)
logger.level = ActiveSupport::BufferedLogger.const_get(configuration.log_level.to_s.upcase)
if configuration.environment == "production"
logger.auto_flushing = false
end
rescue StandardError => e
logger = ActiveSupport::BufferedLogger.new(STDERR)
logger.level = ActiveSupport::BufferedLogger::WARN
logger.warn(
"Rails Error: Unable to access log file. Please ensure that #{configuration.log_path} exists and is chmod 0666. " +
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
)
end
end
silence_warnings { Object.const_set "RAILS_DEFAULT_LOGGER", logger }
end