3

这是一个普通的 Rails 3.2 日志文件条目的样子:

Started GET "/admin" for 127.0.0.1 at 2013-08-05 14:36:43 +0200  
Processing by Admin::PagesController#show as HTML  
  Parameters: {"id"=>"admin/dashboard"}  
  Post Load (1.5ms)  SELECT 'posts'.* FROM 'posts' WHERE 'posts'.'riddle' = 1 AND 'posts'.'solved_at' <= '2013-08-05 12:36:43' ORDER BY comments_count DESC LIMIT 1  
  [...]  
  CACHE (0.0ms)  SELECT 'comments'.* FROM 'comments' WHERE 'comments'.'post_id' = 74 ORDER BY 'comments'.'id' DESC LIMIT 1  
   (0.3ms)  SELECT COUNT(*) FROM 'posts' WHERE 'posts'.'riddle' = 1  
  Rendered admin/dashboard.html.haml within layouts/admin (109.1ms)  
  Rendered shared/admin/_header.html.haml (3.8ms)  

问题:在我的一个应用程序中,前导行Processing ...Parameters: ...尾随Rendered ...行丢失了,我终生无法弄清楚原因!

Started GET "/admin" for 127.0.0.1 at 2013-08-05 14:36:43 +0200  
  Post Load (1.5ms)  SELECT 'posts'.* FROM 'posts' WHERE 'posts'.'riddle' = 1 AND 'posts'.'solved_at' <= '2013-08-05 12:36:43' ORDER BY comments_count DESC LIMIT 1  
  [...]  
  CACHE (0.0ms)  SELECT 'comments'.* FROM 'comments' WHERE 'comments'.'post_id' = 74 ORDER BY 'comments'.'id' DESC LIMIT 1  
   (0.3ms)  SELECT COUNT(*) FROM 'posts' WHERE 'posts'.'riddle' = 1  

该应用程序太大,包含太多宝石,无法在此处发布相关部分,但我尝试在开发中删除宝石,验证日志级别设置为:debug,记录器是标准级别等。

有没有人见过这个?

4

1 回答 1

1

检查Loggerused byActionController::Base是否与应用程序其余部分使用的相同。在 rails 控制台中,ActionController::Base.logger == Rails.logger应该是true.

如果是false,则该应用程序在某处设置了特定LoggerActionController::Base使用方式,例如ActionController::Base.logger = ActiveSupport::TaggedLogging.new(Logger.new('log/controllers.log'))

于 2013-09-09T12:24:58.317 回答