我正在尝试将生产环境日志保存到其他服务器上的数据库中。我的意思是当显示某些错误时我想打开ssh并检查production.log的结尾..我想要的是去到其他数据库(也许在其他服务器上)蚂蚁检查出来。
我希望记录的信息与我在* .log中看到的相同,包含错误的代码跟踪,错误发现的行,数据库查询和HTTP响应。
像这样,Processing Admin::WelcomeController#login (for XXX.XXX.XXX.XXX at 2010-08-27 00:02:41) [POST]
Parameters: {"username_or_email"=>"admin", "action"=>"login", "authenticity_token"=>"oPMZYGi+k/Wvxxxxxv2oNU0w34PV2KNSENuwn8=", "controller"=>"admin/welcome", "password"=>"[FILTERED]"}
Redirected to http://beta.site.com/admin/pages
Completed in 19ms (DB: 13) | 302 Found [http://beta.site.com/admin/login]
等等
Processing Admin::PagesController#edit (for 213.6.226.204 at 2010-09-02 14:18:43) [GET]
Parameters: {"action"=>"edit", "id"=>"14", "controller"=>"admin/pages"}
Rendering template within layouts/application
Rendering admin/pages/edit
ActionView::TemplateError (undefined method `include?' for nil:NilClass) on line #26 of /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/radiant-0.9.1/app/views/admin/pages/_fields.html.haml:
23: %a.popup{:href=> '#add_part_popup', :title=>t('add_part')}
24: = image('add_tab', :alt=>t('add_part'), :title=>"")
25: #pages.pages
26: = render :partial => 'admin/page_parts/page_part', :collection => @page.parts
27: = render_region :parts_bottom, :locals => {:f => fields}
28: - form.edit_layout_and_type do
29: .set
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/will_paginate-2.3.14/lib/will_paginate/finder.rb:168:in `method_missing'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers/action_view_mods.rb:11:in `render'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers.rb:90:in `non_haml'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers/action_view_mods.rb:11:in `render'
radiant (0.9.1) app/views/admin/pages/_fields.html.haml:26
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers.rb:343:in `call'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers.rb:343:in `capture_haml'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers.rb:545:in `with_haml_buffer'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers.rb:339:in `capture_haml'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers/action_view_mods.rb:88:in `capture'
radiant (0.9.1) lib/radiant/admin_ui/region_partials.rb:13:in `method_missing'
radiant (0.9.1) app/views/admin/pages/_fields.html.haml:19
radiant (0.9.1) app/helpers/admin/regions_helper.rb:6:in `call'
radiant (0.9.1) app/helpers/admin/regions_helper.rb:6:in `render_region'
radiant (0.9.1) app/views/admin/pages/_fields.html.haml:6:in `_run_haml_47opt47ruby45enterprise47lib47ruby47gems47146847gems47radiant45046946147app47views47admin47pages47_fields46html46haml_locals_fields_object'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers/action_view_mods.rb:11:in `render'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers.rb:90:in `non_haml'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers/action_view_mods.rb:11:in `render'
radiant (0.9.1) app/views/admin/pages/edit.html.haml:8
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers/action_view_mods.rb:204:in `call'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers/action_view_mods.rb:204
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers.rb:567:in `call'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers.rb:567:in `haml_bind_proc'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers/action_view_mods.rb:210:in `form_for'
radiant (0.9.1) app/views/admin/pages/edit.html.haml:7
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers.rb:343:in `call'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers.rb:343:in `capture_haml'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers.rb:545:in `with_haml_buffer'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers.rb:339:in `capture_haml'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers/action_view_mods.rb:88:in `capture'
radiant (0.9.1) lib/radiant/admin_ui/region_partials.rb:13:in `method_missing'
radiant (0.9.1) app/views/admin/pages/edit.html.haml:6
radiant (0.9.1) app/helpers/admin/regions_helper.rb:6:in `call'
radiant (0.9.1) app/helpers/admin/regions_helper.rb:6:in `render_region'
radiant (0.9.1) app/views/admin/pages/edit.html.haml:3:in `_run_haml_47opt47ruby45enterprise47lib47ruby47gems47146847gems47radiant45046946147app47views47admin47pages47edit46html46haml'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers/action_view_mods.rb:13:in `render'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/haml/helpers/action_view_mods.rb:13:in `render'
radiant (0.9.1) vendor/plugins/haml/rails/./lib/sass/plugin/rails.rb:20:in `process'
passenger (2.2.11) lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'
passenger (2.2.11) lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
passenger (2.2.11) lib/phusion_passenger/railz/application_spawner.rb:418:in `start_request_handler'
passenger (2.2.11) lib/phusion_passenger/railz/application_spawner.rb:358:in `handle_spawn_application'
passenger (2.2.11) lib/phusion_passenger/utils.rb:184:in `safe_fork'
passenger (2.2.11) lib/phusion_passenger/railz/application_spawner.rb:354:in `handle_spawn_application'
passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in `__send__'
passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:163:in `start'
passenger (2.2.11) lib/phusion_passenger/railz/application_spawner.rb:213:in `start'
passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:262:in `spawn_rails_application'
passenger (2.2.11) lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:256:in `spawn_rails_application'
passenger (2.2.11) lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
passenger (2.2.11) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application'
passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:154:in `spawn_application'
passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application'
passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in `__send__'
passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
Rendering /home/deploy/xxxx/public/500.html (500 Internal Server Error)
欢迎任何技巧:)
阿姆鲁
答案 0 :(得分:1)
答案 1 :(得分:-1)
Rails记录器显然不能做你想要的开箱即用。
一种选择是写入syslog(http://www.blueboxgrp.com/news/2009/06/unified_rails_logging_with_syslogng)并使用可以将日志条目推送到数据库的syslog-ng(mysql,postgres, sqlite,http://chaos.untouchable.net/index.php/HOWTO_setup_syslog-ng_to_log_to_mysql)。您必须进行一些配置才能使这一切工作,并调整rails以在生产模式下配置更多信息。问题在于,每当您的应用程序收到请求时,它都会多次写入日志,因此您将为数据库中的每个请求获取多条记录。
今年在Rails Rumble期间还创建了另一项服务(抱歉插件!)http://logbook.me,您可以使用它来记录任何内容。使用当前版本的gem,您需要手动完成一些工作(捕获异常,捕获您感兴趣的详细信息+回溯并将其传递给服务),但我们计划扩展它以便它自动做更多的东西。