我尝试根据本文使用Rails 3.0.4配置log4r:http://www.dansketcher.com/2007/06/16/integrating-log4r-and-ruby-on-rails/
/Users/toto/.rvm/gems/ruby-1.9.2-p0/gems/log4r-1.1.9/lib/log4r/yamlconfigurator.rb:166:in `sub!': can't convert Pathname into String (TypeError)
from /Users/toto/.rvm/gems/ruby-1.9.2-p0/gems/log4r-1.1.9/lib/log4r/yamlconfigurator.rb:166:in `block in paramsub'
from /Users/toto/.rvm/gems/ruby-1.9.2-p0/gems/log4r-1.1.9/lib/log4r/yamlconfigurator.rb:165:in `each'
from /Users/toto/.rvm/gems/ruby-1.9.2-p0/gems/log4r-1.1.9/lib/log4r/yamlconfigurator.rb:165:in `paramsub'
from /Users/toto/.rvm/gems/ruby-1.9.2-p0/gems/log4r-1.1.9/lib/log4r/yamlconfigurator.rb:156:in `block in decode_hash_params'
Run Code Online (Sandbox Code Playgroud)
我已经谷歌搜索Rails 3集成,但还没有找到一个有效的解决方案.任何人都可以指向一个工作的代码片段,允许使用YAML文件进行日志配置,并在运行时初始化?
作为参考,我将示例logger.rb放在config/initializers文件夹中,将log4r.yml放在config目录中.
谢谢
我试图在我的Rails日志中获取更多信息,特别是请求的URI或当前参数(如果可用)(我感谢他们并不总是这样).但是我似乎无法做到.这是我到目前为止所做的:
#config/environments/production.rb
config.logger = Logger.new(config.log_path)
config.log_level = :error
config.logger.level = Logger::ERROR
#config/environment.rb
class Logger
def format_message(level, time, progname, msg)
"**********************************************************************\n#{level} #{time.to_s(:db)} -- #{msg}\n"
end
end
Run Code Online (Sandbox Code Playgroud)
所以我可以自定义消息,但我似乎无法在这里访问params/request变量.有谁知道这是否可能,如果是这样的话怎么样?或者,如果有更好的方法来获取此信息?(甚至可能是Redis的基础?)
谢谢你,
担
我tail -f在开发Rails应用程序时用来显示日志文件.它显示了日志消息(颜色!:),这很棒.
但是,如果在80宽度控制台中有如此多的信息,那么当我点击按钮获取资源时,很难跟踪某些"设置"日志消息的开始位置.
如果在每条日志消息/行的开头有行号或甚至是时间戳,则会更容易.这样我就记得我需要开始查看"行号2365"或"2010/10/10 23:33:23:45之后"的日志.
这可能吗?是否有一些Rails内部选项?
Rails 3内置记录器和Log4r之间的主要区别是什么?在我看来,Rails 3记录器为您提供了所需的一切.