# Stopping WEBrick from logging

**URL:** <https://www.ruby-forum.com/t/stopping-webrick-from-logging/101945>\
**Category:** Ruby\
**Created:** [August 8, 2006, 8:39pm UTC](https://www.ruby-forum.com/t/stopping-webrick-from-logging/101945 "2006-08-08T20:39:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![regularfry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@regularfry](https://www.ruby-forum.com/u/regularfry)\
**Post date:** [August 8, 2006, 8:39pm UTC](https://www.ruby-forum.com/t/stopping-webrick-from-logging/101945/1 "2006-08-08T20:39:26Z")

</div>

Hi all,

I’m doing some local timing of some network code, and I’m using  
WEBrick::HTTPProxyServer to mock out the actual network access to reduce  
some of the variability.

What I’d like to do is stop the access logging from happening. That is,  
I don’t want the access logs to fill up stdout or stderr, because  
they’re used in my code and I want its output to stay clean. I also  
don’t want the logs going to a string or array in memory, because it’ll  
fill up and make everything swap endlessly. Ideally, I want the access  
logging to just not happen, and I just can’t see how to do that.

Any ideas?

---

<div class="post-metadata">

**Author:** ![regularfry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@regularfry](https://www.ruby-forum.com/u/regularfry)\
**Post date:** [August 8, 2006, 8:54pm UTC](https://www.ruby-forum.com/t/stopping-webrick-from-logging/101945/2 "2006-08-08T20:54:28Z")

</div>

Could you redirect to a StringIO pointed at /dev/null? Without looking  
at the WEBrick API, I wouldn’t know right off how to change the  
destination of the logging messages. That’s the best I can help you  
for now.

M.T.

---

<div class="post-metadata">

**Author:** ![regularfry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@regularfry](https://www.ruby-forum.com/u/regularfry)\
**Post date:** [August 8, 2006, 9:00pm UTC](https://www.ruby-forum.com/t/stopping-webrick-from-logging/101945/3 "2006-08-08T21:00:28Z")

</div>

Alex Y. wrote:

> fill up and make everything swap endlessly. Ideally, I want the access  
> logging to just not happen, and I just can’t see how to do that.
> 
> Any ideas?

Ah. It would seem I should read a few more of the docs before posting.

Apparently doing this:

def access\_log(\*args); end

in the server class does the trick.

Not exactly intuitive, though…

---

<div class="post-metadata">

**Author:** ![regularfry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@regularfry](https://www.ruby-forum.com/u/regularfry)\
**Post date:** [August 8, 2006, 9:03pm UTC](https://www.ruby-forum.com/t/stopping-webrick-from-logging/101945/4 "2006-08-08T21:03:29Z")

</div>

Matt T. wrote:

> Could you redirect to a StringIO pointed at /dev/null? Without looking  
> at the WEBrick API, I wouldn’t know right off how to change the  
> destination of the logging messages. That’s the best I can help you  
> for now.
> 
> M.T.

Thanks… I might try that next time. For now I’m overriding  
HTTPProxyServer#access\_log.

---

<div class="post-metadata">

**Author:** ![regularfry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@regularfry](https://www.ruby-forum.com/u/regularfry)\
**Post date:** [August 8, 2006, 9:12pm UTC](https://www.ruby-forum.com/t/stopping-webrick-from-logging/101945/5 "2006-08-08T21:12:29Z")

</div>

On 8/8/06, Alex Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> fill up and make everything swap endlessly. Ideally, I want the access  
> logging to just not happen, and I just can’t see how to do that.
> 
> Any ideas?

in your HTTPServer (or any descendant of GenericServer) write

```
   logger.level = 0

```

you can do it from the outside as well.

your\_server.logger.level = 0

For more details read the sources 😉

J.
