Rails logger.silence on controller action

I’ve got a simple controller which is being hit every minute to monitor
the website. I’ve read in a few places, and on this group as well that
if you include a logger.silence around the code, it shouldn’t appear in
the log. With the controller below, I get log entries every time the
action is called. I’m just wondering what I may be doing wrong.

Thanks.

CONTROLLER:
class MonitController < ActionController::Base
session :off

this is used by the monitoring scripts to see if the mongrel is up

and running
def index
logger.silence do
render :text => ‘success’
end
end
end

LOG OUTPUT:
Processing MonitController#index (for 127.0.0.1 at 2007-01-23 12:18:45)
[GET]
Parameters: {“action”=>“index”, “controller”=>“monit”}
Completed in 0.00349 (286 reqs/sec) | Rendering: 0.00007 (2%) | DB:
0.00000 (0%) | 200 OK [http:// /monit/index]

Just wondering if any solution was found for this - I’m in exactly the
same position, looking to suppress Monit actions from appearing in my
log. Wrapping the action in logger.silence seems to have no effect,
nor does forcibly increasing the logger.level to try and filter it
out.

I’m on Rails 1.1.6 - is it perhaps a 1.2+ thing only?

Cheers,
Mike

Doesn’t appear to be (even in 1.2+), other than monkey patching
ActionController::Base#log_processing for your needs.

If you’re doing this to see if Mongrel is up, why not write a simple
handler and place it in config/mongrel.conf? This won’t get logged
anywhere, and is way faster than going to rails for it:

lib/monit_handler.rb

class MonitHandler < Mongrel::HttpHandler
def process(request, response)
response.start { |head, out| out.write(“I’m up…”) }
end
end

config/mongrel.conf

uri “/monit”, :handler => MonitHandler.new

Then in your production scripts, you need to pass in an extra switch
to mongrel so it’ll use config/mongrel.conf. If you’re using mongrel
cluster, add:

config_script: config/mongrel.conf

to your config/mongrel_cluster.yml

I did find a way around it. Putting a def logger end in the controller
short circuits the logger from running and nothing is ever written to
the log files. This has also had the added benefit of removing a large
amount of memory usage for my application over time.

Also, I thought about going the mongrel handler route, but this works
for now.

CONTROLLER:
class MonitController < ActionController::Base
session :off

this is used by the monitoring scripts to see if the mongrel is

up and running
def index
end
def logger
end
end