开发者

How do I get rid of the rails3 warning: DEPRECATION WARNING: RAILS_DEFAULT_LOGGER is deprecated

开发者 https://www.devze.com 2023-03-22 13:09 出处:网络
Here is the full warning: DEPRECATION WARNING: RAILS_DEFAULT_LOGGER is deprecated. Please use ::Rails.logger. (called fromat /Users/timmar开发者_运维技巧tin/src/edcaliber/config/environment.rb:7)

Here is the full warning:

DEPRECATION WARNING: RAILS_DEFAULT_LOGGER is deprecated. Please use ::Rails.logger. (called from at /Users/timmar开发者_运维技巧tin/src/edcaliber/config/environment.rb:7)

My tree does not contain 'RAILS_DEFAULT_LOGGER' and line 7 of environment.rb is just:

MyApplication::Application.initialize!

How can I get rid of this warning? I recently upgraded from rails2


That's probably from one of the plugins you are using. Dig around and see if you can find which one it is.


Got the same warning message on my Rails 3 app, where I had explicitly used RAILS_DEFAULT_LOGGER in one of the files; replacing it with ::Rails.logger made the warning message go away.

Looks like there might be an instance of RAILS_DEFAULT_LOGGER in one of the other config files in your app. Try finding for that string in your app.

Running the following command from your rails app home directory should show you where it is.

grep -r RAILS_DEFAULT_LOGGER *


If it's not in your code, it's in a gem somewhere. Here's a bash one-liner to search your gems:

find `gem environment | grep "INSTALLATION DIR" | cut -d: -f2` | grep rb$ | xargs grep RAILS_DEFAULT_LOGGER

For me it looked like webrat, railties, and newrelic are all using RAILS_DEFAULT_LOGGER.

If you'd like to learn how to fish instead of just eating this fish, or you don't just paste scripts into a terminal when some guy on the internet tells you to, here's how to do it step-by-step yourself. First run

gem environment

to see where your gems' ruby code gets installed. For me, that directory appeared to be listed as "INSTALLATION DIRECTORY" and it was /home/lacker/.rvm/gems/ruby-1.8.7-p352 . The next step is to get a listing of all the files ending in "rb" in those gems:

find /home/lacker/.rvm/gems/ruby-1.8.7-p352 | grep rb$

Now we want to grep each of those for RAILS_DEFAULT_LOGGER, which you can use xargs + grep for:

find /home/lacker/.rvm/gems/ruby-1.8.7-p352 | grep rb$ | xargs grep RAILS_DEFAULT_LOGGER

You can also use Ack for this, if you have that installed.

0

精彩评论

暂无评论...
验证码 换一张
取 消