Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

config.log_level is ignored when setting a custom logger

#3500

This behaviour is the same whether the log_level is set before or after setting the logger:

# config.log_level = :info
config.logger = Logger.new(config.log_path, 30, 1.megabyte)
config.log_level = :info

What happens is that the log output is unfiltered (as in :debug). It still says Rails.configuration.log_level is :info, but the log output includes SQL queries, etc.

I worked around it by setting it thus:

config.logger = Logger.new(config.log_path, 50, 1.megabyte)
config.log_level = :info
config.logger.level = Logger::INFO

Reported by Andrew Vit · November 20th, 2009 @ 10:59 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Matt Jones
    Matt Jones
    • State changed from new to invalid

    This is the expected behavior - if you're setting config.logger explictly, Rails uses whatever you're passing in without further configuration.

    November 22nd, 2009 @ 07:54 AM

  2. Andrew Vit
    Andrew Vit

    In that case, wouldn't it make sense to remove/deprecate config.log_level in favour of setting it directly on the logger object via config.logger.level=... ?

    The way it currently works just adds confusion.

    November 22nd, 2009 @ 08:18 AM

  3. Matt Jones
    Matt Jones

    If you're using the standard logger, config.logger.level= will blow up (NoMethodError on nil), as the logger doesn't exist yet when the environment is being loaded. (it gets set up in initialize_logger)

    November 22nd, 2009 @ 08:24 AM