Hi there, I''m wondering if there''s a way to have any log statements generated from a specific method on a model get logged into a separate file from the normal development/production log files? i.e. I want the whole app to log as normal, apart from the Sprinter.run_often method, which I''d like to log to sprinter_running.log Cheers, Tim.
Ivan Porto Carrero
2009-Apr-30 07:57 UTC
Re: Logging - using a different log for one method
I guess it would be something like sprinter_log = BufferedLogger.new("sprinter_runner.log") sprinter_log.log(''yay I''m logging'') On 30 apr, 06:37, Tim Haines <TMHai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi there, > > I''m wondering if there''s a way to have any log statements generated > from a specific method on a model get logged into a separate file from > the normal development/production log files? > > i.e. I want the whole app to log as normal, apart from the > Sprinter.run_often method, which I''d like to log to > sprinter_running.log > > Cheers, > > Tim.
Hi Ivan, Thanks - I thought I was probably missing a detail. That will put my own log statements into a new log. But what I''m aiming for is to get AR generated log statements into the separate log file also. Without interfering with whatever other code is running concurrently. Cheers, Tim. On Apr 30, 4:57 pm, Ivan Porto Carrero <i...-wX+4I8mn6UTJKwlM9GxbOw@public.gmane.org> wrote:> I guess it would be something like > > sprinter_log = BufferedLogger.new("sprinter_runner.log") > > sprinter_log.log(''yay I''m logging'') > > On 30 apr, 06:37, Tim Haines <TMHai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi there, > > > I''m wondering if there''s a way to have any log statements generated > > from a specific method on a model get logged into a separate file from > > the normal development/production log files? > > > i.e. I want the whole app to log as normal, apart from the > > Sprinter.run_often method, which I''d like to log to > > sprinter_running.log > > > Cheers, > > > Tim. > >
Ivan Porto Carrero
2009-Apr-30 08:19 UTC
Re: Logging - using a different log for one method
Monkey patch ActiveRecord::Base or your base class and override logger def logger @logger = BufferedLogger.new(''name'') end On 30 apr, 10:09, Tim Haines <TMHai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Ivan, > > Thanks - I thought I was probably missing a detail. That will put my > own log statements into a new log. But what I''m aiming for is to get > AR generated log statements into the separate log file also. Without > interfering with whatever other code is running concurrently. > > Cheers, > > Tim. > > On Apr 30, 4:57 pm, Ivan Porto Carrero <i...-wX+4I8mn6UTJKwlM9GxbOw@public.gmane.org> wrote: > > > I guess it would be something like > > > sprinter_log = BufferedLogger.new("sprinter_runner.log") > > > sprinter_log.log(''yay I''m logging'') > > > On 30 apr, 06:37, Tim Haines <TMHai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi there, > > > > I''m wondering if there''s a way to have any log statements generated > > > from a specific method on a model get logged into a separate file from > > > the normal development/production log files? > > > > i.e. I want the whole app to log as normal, apart from the > > > Sprinter.run_often method, which I''d like to log to > > > sprinter_running.log > > > > Cheers, > > > > Tim.