Hi all, I have my Rails logging level turned up high in production because it helps me find bugs. The problem is, there are some actions that I don''t want logged, such as my monitor action. This action is called every 30 seconds to ensure the server is up and running fine. The logs generated from this action simply pollute the log; is there any way to turn these off but leave all the other actions log levels unchanged? Thanks! --Dave.
On Aug 1, 2005, at 8:36 AM, David Teare wrote:> Hi all, > > I have my Rails logging level turned up high in production because > it helps me find bugs. The problem is, there are some actions that > I don''t want logged, such as my monitor action. This action is > called every 30 seconds to ensure the server is up and running > fine. The logs generated from this action simply pollute the log; > is there any way to turn these off but leave all the other actions > log levels unchanged?Dave, You can do the following: def monitor logger.silence do ... end end The #silence method is a Rails addition to logger that temporarily bumps the log level up to ERROR for the duration of the block. If you want it to be a little more verbose than that, you can also specify the log level explicitly: logger.silence(Logger::WARN) do ... end - Jamis
That makes sense. Thanks for the quick reply! On 1-Aug-05, at 10:45 AM, Jamis Buck wrote:> On Aug 1, 2005, at 8:36 AM, David Teare wrote: > > >> Hi all, >> >> I have my Rails logging level turned up high in production because >> it helps me find bugs. The problem is, there are some actions >> that I don''t want logged, such as my monitor action. This action >> is called every 30 seconds to ensure the server is up and running >> fine. The logs generated from this action simply pollute the log; >> is there any way to turn these off but leave all the other actions >> log levels unchanged? >> > > Dave, > > You can do the following: > > def monitor > logger.silence do > ... > end > end > > The #silence method is a Rails addition to logger that temporarily > bumps the log level up to ERROR for the duration of the block. If > you want it to be a little more verbose than that, you can also > specify the log level explicitly: > > logger.silence(Logger::WARN) do > ... > end > > - Jamis > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >