Skip to content
This repository
Browse code

Use Rails.logger, not ActiveRecord::Base.logger

Because everybody is not using ActiveRecord. And the logger is not specific to it.
  • Loading branch information...
commit 70e4403e46ad536399c7df9f64aa257c5a45b801 1 parent 41e5e4a
Damien Mathieu authored November 08, 2010 fxn committed November 15, 2010
8  railties/guides/source/debugging_rails_applications.textile
Source Rendered
@@ -127,8 +127,8 @@ Rails makes use of Ruby's standard +logger+ to write log information. You can al
127 127
 You can specify an alternative logger in your +environment.rb+ or any environment file:
128 128
 
129 129
 <ruby>
130  
-ActiveRecord::Base.logger = Logger.new(STDOUT)
131  
-ActiveRecord::Base.logger = Log4r::Logger.new("Application Log")
  130
+Rails.logger = Logger.new(STDOUT)
  131
+Rails.logger = Log4r::Logger.new("Application Log")
132 132
 </ruby>
133 133
 
134 134
 Or in the +Initializer+ section, add _any_ of the following
@@ -142,13 +142,13 @@ TIP: By default, each log is created under +Rails.root/log/+ and the log file na
142 142
 
143 143
 h4. Log Levels
144 144
 
145  
-When something is logged it's printed into the corresponding log if the log level of the message is equal or higher than the configured log level. If you want to know the current log level you can call the +ActiveRecord::Base.logger.level+ method.
  145
+When something is logged it's printed into the corresponding log if the log level of the message is equal or higher than the configured log level. If you want to know the current log level you can call the +Rails.logger.level+ method.
146 146
 
147 147
 The available log levels are: +:debug+, +:info+, +:warn+, +:error+, and +:fatal+, corresponding to the log level numbers from 0 up to 4 respectively. To change the default log level, use
148 148
 
149 149
 <ruby>
150 150
 config.log_level = Logger::WARN # In any environment initializer, or
151  
-ActiveRecord::Base.logger.level = 0 # at any time
  151
+Rails.logger.level = 0 # at any time
152 152
 </ruby>
153 153
 
154 154
 This is useful when you want to log under development or staging, but you don't want to flood your production log with unnecessary information.

0 notes on commit 70e4403

Please sign in to comment.
Something went wrong with that request. Please try again.