tags:

views:

45

answers:

1

Why

Is there a reason Rack's request log by default outputs to stderr? If i'm not mistaken, the request log is Rack::CommonLogger which according to the RDoc:

forwards every request to an app given, and logs a line in the Apache common log format to the logger, or rack.errors by default.

Doesn't it make more sense to have an access and error request log instead of pushing everything to rack.errors?

How

How does one redirect the request log to a file? All examples I came across are specifically for sinatra. Can it be disabled completely? (redirect to /dev/null?)

A: 

I have the same question. But I hack a little this logger to switch logger like I want.

You can see the code here :

http://github.com/shingara/sinatra-request-logger/blob/master/lib/sinatra/request-logger.rb

Rack::CommonLogger use rack.errors where there are data. It's a StringIO by default. So you can't put a Logger inside. You need made a Proxy to put in your logger.

shingara