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 Rochkind 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!

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Deploying Rails" group.
To post to this group, send email to rubyonrails-deployment@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-deployment?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to