Can you really obtain the full Web addresses within the logs of the Rails application? Presently I am getting something similar to:

Began GET "/" for 127...1 at 2011-08-27 13:13:10 +0200

but I have to get:

Began GET "http://localhost:3000/" for 127...1 at 2011-08-27 13:13:10 +0200

since this is an application in which the domain names are essential.

The road is from the middleware Rails::Rack::Logger, that is in railties. In the easiest, you can just override the technique doing the logging, e.g., within an initializer:

class Rails::Rack::Logger < ActiveSupport::LogSubscriber


  def before_dispatch(env)

    request =

    info "nnStarted # "#" for # at #"



If you would rather not override the logger, you can always add your personal, which you've already produced, then remove Rails::Rack::Logger in the stack via:

config.middleware.place_before(Rails::Rack::Logger, YourLogger)


Should you follow this path you may browse the rack logger because of its using ActionDispatch::Request, and make certain to complete another job it will of eliminating the log customer cache after dispatch, via ActiveSupport::LogSubscriber.flush_all!

I do not think this can be done without altering Rails itself, which is not nice, but you can include your personal log call:

class ApplicationController < ActionController::Base

  before_filter :log_request


  def log_request"Began # #")



A workaround I am using for the time being was creating these kinds:

class HostnameLogger

  def initialize(application)

    @application = application


  def call(env)

    uri = env["REQUEST_URI"]

    if uri.blank? # While testing a Rails application, there is no env["REQUEST_UIR"] defined.

      uri = "http://##"

    finish "Began # "#" for # at #"



after which adding it as being Rack middleware (in application.rb):

config.middleware.use "HostnameLogger"

and so i get:

Began GET "/customers/login" for 127...1 at 2011-08-27 15:33:40 +0200

Began GET "http://localhost:3000/customers/login" for 127...1 at 2011-08-27 15:33:40 +0200