config.logger level is overwritten

Skip to first unread message

Morteza Milani

Mar 23, 2020, 3:47:45 PM3/23/20
to Ruby on Rails: Talk
Hello all,

I have a comment about rails logger and I wish to change its behaviour.

Rails tries to load the logger from config like this:

Rails.logger ||= config.logger || begin
logger =

Then later after the above block, it sets the logger level:

Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)

The problem is that this overwrites the level that is set in the config.logger. In normal cases, it is no problem. But when different logging classes are embedded
and they depend on the log level, this makes a problem since the final value of the logger will be different from the value set in the config.logger.

Moreover, it is more intuitive to expect the logging level set on the object provided rather than config.log_level.

Reply all
Reply to author
0 new messages