views:

33

answers:

2

I'm trying to save the Production environment log to the database on other server.. What I mean that when some errors shown I want to open ssh and check the end of production.log.. What I want is to go to the other database (on other server maybe) ant check it out.

I want the logged information to be the same as I see in the *.log, contains code tracing of an error, the line that the error found in, database queries, and HTTP responses..

like this,

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]

and something like that

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)

any trick is welcomed :)

Amr

+1  A: 

Hoptoad. http://hoptoadapp.com/

SteveRawlinson
Well, I know it and vote it up for the service. but I want the functionality of the Rails logger to do such job.
amrnt
+1  A: 

Rails logger obviously can't do what you want out of the box.

One option would be to write to syslog (http://www.blueboxgrp.com/news/2009/06/unified_rails_logging_with_syslog-ng) and use syslog-ng that can push log entries to a database (mysql, postgres, sqlite, http://chaos.untouchable.net/index.php/HOWTO_setup_syslog-ng_to_log_to_mysql). You'll have to do some configuration to make this all work, plus tweak rails to config more info in production mode. The problem is that every time your app gets a requests it writes to the log several times, so you'll get several records for every request in the database.

There's also another service that has been created during Rails Rumble this year (sorry for the plug!) http://logbook.me that you could use to log just anything. With the current version of the gem you'd need to do some work manually (catch the exception, capture details that you're interested in + backtrace and pass them to the service), but we're planning to extend it so that it does more stuff automatically.

Eugene Bolshakov