Stopping WEBrick from logging

A

Alex Young

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?
 
M

Matt Todd

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.
 
A

Alex Young

Alex said:
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?
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...
 
A

Alex Young

Matt said:
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.
 
J

Jan Svitok

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?

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top