class ApplicationController < ActionController::Base
before_action :init_logger
def home
logger.info 'test'
end
def init_logger
logger = MyLogger.new(env)
Rails.logger = logger
end
end
This does not work as expected because the logger in the home action is not the same logger in the before action. The logger in the home action is the default Rails logger.
How to set the Rails logger in the before action?