Referrer logging?

Is the default Rails production.log supposed to log referrer with every
request?

I see that there is ‘info’ level logging of each incoming request. But
in my logs, they don’t have ‘referrer’ logged. Is this because default
Rails logging doesn’t do this, or is this because my mongrel setup is
eating the referrer somehow?

What’s the easiest way to add referrer logging to Rails logging? I like
the logging of each request, I just want to know the referrer for every
request too. (Mainly to help me with debugging; if an error happened in
a request, it’s helpful to know if the URL came from an external link or
from my application itself).

Thanks for any help!

To answer my own question from a month ago, to add logging of HTTP
referer (spelled right) into a Rails (1.2.x; can’t speak for 2.x) app,
override log_processing in application.rb:

def log_processing
super
if logger && logger.info?
logger.info(" HTTP Referer: #{request.referer}")
end
end

Seems to work nicely. Since sometimes referers can be long, you may or
may not want to truncate to some value:

  logger.info("  HTTP Referer: #{request.referer[0..100]}")

Jonathan

Jonathan R. wrote:

Is the default Rails production.log supposed to log referrer with every
request?

I see that there is ‘info’ level logging of each incoming request. But
in my logs, they don’t have ‘referrer’ logged. Is this because default
Rails logging doesn’t do this, or is this because my mongrel setup is
eating the referrer somehow?

What’s the easiest way to add referrer logging to Rails logging? I like
the logging of each request, I just want to know the referrer for every
request too. (Mainly to help me with debugging; if an error happened in
a request, it’s helpful to know if the URL came from an external link or
from my application itself).

Thanks for any help!