Question about WEBrick console logging

M

Morgan

I'm writing a WEBrick server that I want to output some status
information to the console. However, all the *other* stuff that's
getting output makes my information hard to see. Even after adding
to the server configuration what I *thought* was supposed to make
it only output for fatal errors, I still get the line with my hostname,
the current time, and the request string.

How can I make this go away?

-Morgan.

"Ginger ale. And leave the bottle."
 
W

why the lucky stiff

Morgan said:
I'm writing a WEBrick server that I want to output some status
information to the console. However, all the *other* stuff that's
getting output makes my information hard to see. Even after adding
to the server configuration what I *thought* was supposed to make
it only output for fatal errors, I still get the line with my hostname,
the current time, and the request string.

How can I make this go away?

The *other* stuff is the access log. You can suppress it by assigning
an empty set of outputs:

server = WEBrick::HTTPServer.new( :AccessLog => [] )

Or you could send it to an access log file:

server = WEBrick::HTTPServer.new(
:AccessLog => [[Logger.new('access.log'),
AccessLog::COMMON_LOG_FORMAT]] )

Whatever you choose I'm sure will work out for the best.

_why
 
R

Ryan Leavengood

I'm writing a WEBrick server that I want to output some status
information to the console. However, all the *other* stuff that's
getting output makes my information hard to see. Even after adding
to the server configuration what I *thought* was supposed to make
it only output for fatal errors, I still get the line with my hostname,
the current time, and the request string.

How can I make this go away?

Add this option to the hash you are passing to your server:

:AccessLog =3D> []

The things you see are logged by the access log. By passing an empty
array, nothing is logged. If you pass nil, the default is used:

unless @config[:AccessLog]
@config[:AccessLog] =3D [
[ $stderr, AccessLog::COMMON_LOG_FORMAT ],
[ $stderr, AccessLog::REFERER_LOG_FORMAT ]
]
end

It took me some digging to figure this out...

Ryan
 

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,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top