title: Modify log format and content from default ActionController LogSubscriber in Rails 3
body: <p><strong>Context:</strong></p>
  
  <p>In a rails 3 project I want to customise (heavily) the format and content of the "Processing" and "Completed in" log lines from ActionController.  This is in order to have them match the (also custom) format of an older rails 2.3 app, allowing re-use of various analysis tools.  Making them fixed-field (by use of place-holders where necessary) also makes it far easier  to do ad-hoc queries on them with (say) awk, or to load them into a db or splunk without smart parsing.</p>
  
  <p>I've achieved this goal quickly and heavy-handedly by forking rails and <a href="https://github.com/nbogie/rails/commit/fdcad3e0f8789058209e23296243cac224b9b5c0" rel="noreferrer">patching</a> the LogSubscriber in question, but I am now looking to do it the <em>right</em> way.</p>
  
  <p><strong>Here's what <em>I think</em> I want to do:</strong></p>
  
  <ol>
  <li>Create a <code>LogSubscriber</code> inheriting <code>ActionController::LogSubscriber</code>.</li>
  <li>Override only the <code>start_processing</code> and <code>process_action</code> methods.</li>
  <li><em>Unsubscribe</em> the original <code>ActionController::LogSubscriber</code>, which (sadly) registers itself as soon as the class is loaded.  <strong>This is the step I'm stuck on.</strong></li>
  <li>Attach my custom subscriber to <code>:action_controller</code>, using <code>attach_to</code>.</li>
  </ol>
  
  <p>I note that things would be easier if the hook-up of the default ActionController's log subscriber were done as a config step, rather than <a href="https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/log_subscriber.rb#L62" rel="noreferrer">on class load</a>.</p>
  
  <p><strong>Question:</strong></p>
  
  <p>Assuming the approach outlined above is suitable, how can I unsubscribe or unattach the default log subscriber <a href="https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/log_subscriber.rb" rel="noreferrer"><code>ActionController::LogSubscriber</code></a>?  The base class, <a href="http://api.rubyonrails.org/classes/ActiveSupport/LogSubscriber.html" rel="noreferrer">ActiveSupport::LogSubscriber</a> provides <a href="http://api.rubyonrails.org/classes/ActiveSupport/LogSubscriber.html#method-c-attach_to" rel="noreferrer">attach_to</a> but no means of detaching.</p>
  
  <p>Alternatively, what is the cleanest way of altering the behaviour of (or entirely suppressing) the two methods (start_processing, process_action) in the above mentioned class, <a href="https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/log_subscriber.rb" rel="noreferrer">ActionController::LogSubscriber</a>.</p>
  
  <p>Of course, I'd also welcome any other (maintainable) approach which provides full freedom in customizing the log format of the two lines mentioned.</p>
  
  <p><strong>Unsuitable approaches:</strong></p>
  
  <ul>
  <li>My problem cannot be solved by <em>adding</em> instrumentation, as <a href="https://gist.github.com/566725" rel="noreferrer">documented nicely by mnutt</a>.</li>
  <li>I'd like to avoid monkey-patching, or hacking in a way that may break when the rails implementation (not interface) changes.</li>
  </ul>
  
  <p><strong>References:</strong></p>
  
  <ul>
  <li><a href="http://api.rubyonrails.org/classes/ActiveSupport/LogSubscriber.html" rel="noreferrer">Docs</a> and <a href="https://github.com/rails/rails/blob/master/activesupport/lib/active_support/log_subscriber.rb" rel="noreferrer">Source for <code>ActiveSupport::LogSubscriber</code></a></li>
  <li><a href="https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/log_subscriber.rb" rel="noreferrer">Source for <code>ActionController::LogSubscriber</code></a></li>
  <li><a href="http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html" rel="noreferrer">Docs</a>, <a href="https://github.com/rails/rails/blob/master/activesupport/lib/active_support/notifications.rb" rel="noreferrer">Source</a>, and <a href="http://railscasts.com/episodes/249-notifications-in-rails-3" rel="noreferrer">RailsCast</a> for <a href="https://github.com/rails/rails/blob/master/activesupport/lib/active_support/notifications.rb" rel="noreferrer"><code>ActiveSupport::Notifications</code></a></li>
  </ul>