当我做rails s或rails c时。它给了我这个错误。尝试删除rails并重新安装,然后卸载整个ruby并重新安装两个rails,但ruby仍然存在相同的错误。生成错误的第7行是require 'logger'…在irb中运行这一行也会产生相同的错误。使用ruby1.9.2和rails 3.0.6
一直在寻找解决这个错误几个小时了…几天前一切还好好的,现在好像坏了。可能是我在Gemfile中添加了一个gem破坏了它。
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/core_ext/logger.rb:19:in `require': no such file to load -- logger (LoadError)
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/core_ext/logger.rb:19:in `<top (required)>'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails.rb:7:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails.rb:7:in `<top (required)>'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/all.rb:1:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/all.rb:1:in `<top (required)>'
from /home/milife/apps/justin/lifemap-webapp/config/application.rb:3:in `require'
from /home/milife/apps/justin/lifemap-webapp/config/application.rb:3:in `<top (required)>'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/commands.rb:28:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/commands.rb:28:in `block in <top (required)>'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/commands.rb:27:in `tap'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>
这是一个古老的问题,但如果有人像我一样在这里想知道如何在非rails应用程序中使用activessupport的日志记录器,这里是如何:
# Gemfile
gem 'activesupport'
# your code
require 'active_support/logger`
file_logger = Logger.new('../bot.txt', 'daily')
logger = Logger.new(STDOUT)
logger.extend(ActiveSupport::Logger.broadcast(file_logger))