Folks, Crawling through my production.log file is a pain. Is there any way I can have rails log all this information to a database table, instead of, or in addition to the production.log file? Ideally the DB table would have separate columns for some of the log details, like IP address, controller, action, errors, trace, etc. The idea is that I could then filter the log data to quickly see hits on a particular action, or from a particular IP address, etc. I know I could parse production.log and throw it in the database, but I''d prefer to have that done up front without the need for a log parser. Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
apsoto-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-22 17:37 UTC
Re: Make RoR log to database in addition to production.log
Have you thought of using something like, google analytics, splunk or the rails log analyzer? On Feb 21, 9:19 am, "jszobody" <jszob...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Folks, > > Crawling through my production.log file is a pain. Is there any way I > can have rails log all this information to a database table, instead > of, or in addition to the production.log file? Ideally the DB table > would have separate columns for some of the log details, like IP > address, controller, action, errors, trace, etc. The idea is that I > could then filter the log data to quickly see hits on a particular > action, or from a particular IP address, etc. > > I know I could parse production.log and throw it in the database, but > I''d prefer to have that done up front without the need for a log > parser. > > Thanks--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
apsoto-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-22 17:40 UTC
Re: Make RoR log to database in addition to production.log
Have you thought of using something like, google analytics, splunk or the rails log analyzer? On Feb 21, 9:19 am, "jszobody" <jszob...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Folks, > > Crawling through my production.log file is a pain. Is there any way I > can have rails log all this information to a database table, instead > of, or in addition to the production.log file? Ideally the DB table > would have separate columns for some of the log details, like IP > address, controller, action, errors, trace, etc. The idea is that I > could then filter the log data to quickly see hits on a particular > action, or from a particular IP address, etc. > > I know I could parse production.log and throw it in the database, but > I''d prefer to have that done up front without the need for a log > parser. > > Thanks--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
James Mitchell
2007-Feb-23 07:12 UTC
Re: Make RoR log to database in addition to production.log
I''m doing this in one of my apps... I have a method in my application helper that displays the number of hits (ya, i know, old school hit counter, but what client wants, client gets). So, anyway, in addition to keeping up with the current hit count, I log the header data to the db. ---- module ApplicationHelper def hit_counter log = Log.new log.log_type = ''hit'' log.datetime = Time.now log.save controller.request.env.each do |header| log_detail = LogDetail.new log_detail.log_id = log.id log_detail.detail_key = header[0] log_detail.detail_value = header[1] log_detail.save end log.id + 34873 end ... ... ... ---- class CreateLogs < ActiveRecord::Migration def self.up create_table :logs do |t| t.column :log_type, :string t.column :misc, :string t.column :datetime, :timestamp end create_table :log_details do |t| t.column :log_id, :integer, :null => false t.column :detail_key, :string t.column :detail_value, :string end log = Log.new log.log_type = ''debug'' log.misc = "Initial log creation" log.save end def self.down drop_table :logs drop_table :log_details end end ... add_index :log_details, [:detail_key, :detail_value] I can''t comment on how performant this will be as this hasn''t been in production for very long. If you find a better solution, I''d like to hear about it. -- James Mitchell On 2/22/07, apsoto-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <apsoto-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Have you thought of using something like, google analytics, splunk or > the rails log analyzer? > > On Feb 21, 9:19 am, "jszobody" <jszob...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Folks, > > > > Crawling through my production.log file is a pain. Is there any way I > > can have rails log all this information to a database table, instead > > of, or in addition to the production.log file? Ideally the DB table > > would have separate columns for some of the log details, like IP > > address, controller, action, errors, trace, etc. The idea is that I > > could then filter the log data to quickly see hits on a particular > > action, or from a particular IP address, etc. > > > > I know I could parse production.log and throw it in the database, but > > I''d prefer to have that done up front without the need for a log > > parser. > > > > Thanks > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---