How disable log for entire action?

I need to run some info/debug logging in production environment to find
a very elusive problem.

However, I have load balancers which whack a very simple request very
frequently to ensure the entire app stack is active. I have a controller
with one action dedicated to this monitoring task.

I would really like to stop that entire request from being logged to
eliminate the massive amount of noise it generates with info & debug
messages. So something in the header of the controller would seem
appropriate if possible.

I’ve seen several questions like mine, but no solid answers. I’ve tried
the suggestions found here to no avail.

http://www.ruby-forum.com/topic/163669
http://www.ruby-forum.com/topic/82141

Any new thoughts?

– gw

On Mon, Sep 28, 2009 at 7:22 PM, Greg W. <
[email protected]> wrote:

messages. So something in the header of the controller would seem
– gw

The way I do it:

class PulseController
def logger
end

def index
# render some text if you want a monitor of some sort
end
end

then route whatever your load balancer hits to this controller and
you’re
good.

Jason

Jason R. wrote:

On Mon, Sep 28, 2009 at 7:22 PM, Greg W. <
class PulseController
def logger
end

Heh, that’s brute force but simple :slight_smile: It supresses messages from the
controller alright, but doesn’t supress the database query as part of
that action’s chores (doing a mysql ping as part of the stack check).

But I could possibly tinker further.

– gw

On Sep 28, 2009, at 5:16 PM, Greg W. wrote:

But I could possibly tinker further.

I’m coming in late so maybe this has mentioned…

def my_action
ActiveRecord::Base.silence do
… nothing AR related will show up in the logs…
end
end

Search the rails source for “silence” to make sure I’ve got that down
right.

Philip H. wrote:

On Sep 28, 2009, at 5:16 PM, Greg W. wrote:

But I could possibly tinker further.

I’m coming in late so maybe this has mentioned…

def my_action
ActiveRecord::Base.silence do
… nothing AR related will show up in the logs…
end
end

Search the rails source for “silence” to make sure I’ve got that down
right.

Hmm, logical but nope. Still getting queries logged, but that may be
because I used this technique to add timestamps and log level info to
the log output. Maybe there’s interference. (how could anyone think
timestamps would not be useful in a log ???).

http://nopugs.com/2008/07/10/how-to-get-timestamps-in-your-ruby-on-rails-logs

I’ll fiddle more.

– gw

How about up’ing the logger level temporarily, like


bak_log_level = logger.level
begin
logger.level = Logger::ERROR
# do some stuff …

ensure
logger.level = bak_log_level
end

Jeff

On Sep 28, 5:38 pm, Greg W. [email protected]