This project is archived and is in readonly mode.

#3500 ✓invalid
Andrew Vit

config.log_level is ignored when setting a custom logger

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

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

Comments and changes to this ticket

  • Matt Jones

    Matt Jones November 22nd, 2009 @ 07:54 AM

    • 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.

  • Andrew Vit

    Andrew Vit November 22nd, 2009 @ 08:18 AM

    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.

  • Matt Jones

    Matt Jones November 22nd, 2009 @ 08:24 AM

    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)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages