# Disable Logging Locally Within Rails Rake Task

**URL:** <https://www.ruby-forum.com/t/disable-logging-locally-within-rails-rake-task/142139>\
**Category:** Rails\
**Created:** [July 3, 2008, 7:49pm UTC](https://www.ruby-forum.com/t/disable-logging-locally-within-rails-rake-task/142139 "2008-07-03T19:49:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ea5d25/32.png) [@jobu](https://www.ruby-forum.com/u/jobu)\
**Post date:** [July 3, 2008, 7:49pm UTC](https://www.ruby-forum.com/t/disable-logging-locally-within-rails-rake-task/142139/1 "2008-07-03T19:49:09Z")

</div>

I run rails 2.1 and I have a rails task that imports a lot of data and  
it’s bloating my development log. I’d like to disable (or reduce)  
logging during this particular task, but not globally. I’ve read that  
there is a logger.silence block ([http://wiki.rubyonrails.org/rails/](http://wiki.rubyonrails.org/rails/)  
pages/HowtoSelectivelySuppressLogging) that would do this. But within  
a rake task, how do I reference the logger instance being used to call  
the silence method?

Or is there another way to accomplish this?

---

<div class="post-metadata">

**Author:** ![jobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ea5d25/32.png) [@jobu](https://www.ruby-forum.com/u/jobu)\
**Post date:** [July 3, 2008, 8:04pm UTC](https://www.ruby-forum.com/t/disable-logging-locally-within-rails-rake-task/142139/2 "2008-07-03T20:04:22Z")

</div>

On Jul 3, 6:48 pm, Jobu [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I run rails 2.1 and I have a rails task that imports a lot of data and  
> it’s bloating my development log. I’d like to disable (or reduce)  
> logging during this particular task, but not globally. I’ve read that  
> there is a logger.silence block ([http://wiki.rubyonrails.org/rails/](http://wiki.rubyonrails.org/rails/)  
> pages/HowtoSelectivelySuppressLogging) that would do this. But within  
> a rake task, how do I reference the logger instance being used to call  
> the silence method?  
> Unless you’re doing something magic I would imagine it’s just  
> RAILS\_DEFAULT\_LOGGER.

Fred

---

<div class="post-metadata">

**Author:** ![jobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ea5d25/32.png) [@jobu](https://www.ruby-forum.com/u/jobu)\
**Post date:** [July 4, 2008, 1:01am UTC](https://www.ruby-forum.com/t/disable-logging-locally-within-rails-rake-task/142139/3 "2008-07-04T01:01:30Z")

</div>

On Jul 3, 2:03 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 

Thanks, that was it. FWIW ActiveRecord::Base.logger also worked.
