Question about WEBrick console logging

Discussion in 'Ruby' started by Morgan, Oct 18, 2005.

  1. Morgan

    Morgan Guest

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


    --
    No virus found in this outgoing message.
    Checked by AVG Anti-Virus.
    Version: 7.0.344 / Virus Database: 267.12.1/136 - Release Date: 10/15/2005
    Morgan, Oct 18, 2005
    #1
    1. Advertising

  2. Morgan wrote:

    > 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
    why the lucky stiff, Oct 18, 2005
    #2
    1. Advertising

  3. On 10/18/05, Morgan <> wrote:
    > 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
    Ryan Leavengood, Oct 18, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Finney
    Replies:
    2
    Views:
    989
    Egor Bolonev
    Jun 30, 2003
  2. Lloyd Zusman
    Replies:
    2
    Views:
    393
  3. Alex Young

    Stopping WEBrick from logging

    Alex Young, Aug 8, 2006, in forum: Ruby
    Replies:
    4
    Views:
    109
    Jan Svitok
    Aug 8, 2006
  4. Adam Block
    Replies:
    5
    Views:
    175
    Gal Bar-or
    Jan 10, 2011
  5. Aaron Smith

    WEBrick::Daemon and WEBrick

    Aaron Smith, Mar 9, 2007, in forum: Ruby
    Replies:
    2
    Views:
    307
    Aaron Smith
    Mar 18, 2007
Loading...

Share This Page