config.logger level is overwritten

16 views
Skip to first unread message

Morteza Milani

unread,
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 = ActiveSupport::Logger.new(config.default_log_file)
   
....
end


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
Forward
0 new messages