By default, Rails creates
log directory in a file that is named after the environment
in which the application is running. So in production environment, logs are by default directed to
We will have to define custom loggers if these logs are to be directed to another file or to standard output.
Presence of such custom logic is what enables Rails to direct logs to
development.log file in development environment.
Rails 5, however,
supports logging to STDOUT
in production environment through introduction of new environment variable
In a brand new Rails app, we can see the following snippet in
1if ENV["RAILS_LOG_TO_STDOUT"].present? 2 config.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) 3end
RAILS_LOG_TO_STDOUT to any value we should have the production logs directed to
We can see in the snippet above
config.logger is overwritten.
Therefore now the logs will not be directed to
To opt out of this and revert to the original functionality,
we can either assign a blank value to this environment constant
RAILS_LOG_TO_STDOUT from the list of environment constants.