Disable Logging on a Controller/Action

Does anyone know what the best way to disable logging on a controller
or specific action? I've seen a lot of threads, but no real "best
practice"?

Thanks,
Tom

TomRossi7 wrote:

Does anyone know what the best way to disable logging on a controller
or specific action? I've seen a lot of threads, but no real "best
practice"?

Why would you ever want to do this? An inaccurate log is worse than
none at all.

What's your use case?

Thanks,
Tom

Best,

I have an action being called by a monitoring service.

Leaving this out of the log is not "inaccurate", anymore than not
logging static files referenced is the public folder is "inaccurate".

Thanks,
Tom

TomRossi7 wrote:

I have an action being called by a monitoring service.

Leaving this out of the log is not "inaccurate",

I'm not sure I agree. The log tells you what Rails has been up to. One
of the things it has been up to is servicing the requests that come from
the monitoring service. Leaving those requests out of the log will
lessen the utility of the log.

Consider: if there were a bug or bottleneck in the monitoring request,
how would you know? If the monitoring service weren't requesting its
action, how would you know?

Picking and choosing in the log is a bad idea.

anymore than not
logging static files referenced is the public folder is "inaccurate".

The analogy doesn't hold. The log is specifically a Rails log. Files
in /public aren't served by Rails; therefore, they don't appear in the
log. Your monitoring requests, however, are served by Rails and should
appear in the log.

Thanks,
Tom

Best,

Marnen,

I do appreciate the feedback, but I wonder if others agree? Maybe
that is why its not a simple task within Rails?

Anyone?

Thanks,
Tom

I think logging is a tool, and what you choose to record is up to you.

That said, I have no idea how to selectively turn off the standard Rails
logging. :slight_smile:

I was able to get rid of the usual "Processing blah blah..." message
with e.g.

  def index
    logger.auto_flushing= 0
    @things = Thing.all
    logger.send("clear_buffer")
    logger.auto_flushing= 1000
  end

but the "Rendering template blah blah... " still shows up. Maybe that'll
give you some ideas. Sounds like a good idea for a gem, if selective
(or more configurable) logging isn't part of Rails 3. I haven't looked.

FWIW,

Hi Tom,

Not sure if it applies to your specific case, but whenever I come
across the need to quiet the logging activity for some particular
verbose-under-normal-logging activity process that I'm really only
concerned about logging-wise only if it fails, ... I usually just
temporarily up the log-level for the specific handling of that
process. Something like:

  # in the controller:
  ...
  bak_log_level = logger.level
  begin
    logger.level = Logger::ERROR
    # do some stuff ...
    ...
  ensure
    logger.level = bak_log_level
  end
  ...

Jeff