descriptionconfigurable request logging for Rack
homepage URL
repository URLgit://
last changeFri, 27 Feb 2015 22:53:07 +0000 (27 22:53 +0000)
last refreshMon, 31 Aug 2015 14:35:59 +0000 (31 16:35 +0200)
content tags
= Clogger - configurable request logging for Rack



Clogger is Rack middleware for logging HTTP requests.  The log format
is customizable so you can specify exactly which fields to log.


* highly customizable with easy-to-read nginx-like log format variables.

* pre-defines Apache Common Log Format, Apache Combined Log Format and
  Rack::CommonLogger (as distributed by Rack 1.0) formats.
  See Clogger::Format for the predefined formats.

* Untrusted values are escaped (all HTTP headers, request URI components)
  to make life easier for HTTP log parsers. The following bytes are escaped:

    ' (single quote)
    " (double quote)
    all bytes in the range of \x00-\x1F


Clogger may be loaded as Rack middleware in your

  require "clogger"
  use Clogger,
      :format => Clogger::Format::Combined,
      :logger =>"/path/to/log", "ab")

If you're using Rails 2.3.x or later, in your config/environment.rb
somewhere inside the " do |config|" block:

  config.middleware.use 'Clogger',
      :format => Clogger::Format::Combined,
      :logger =>"/path/to/log", "ab")


* $http_* - HTTP request headers (e.g. $http_user_agent)
* $sent_http_* - HTTP response headers (e.g. $sent_http_content_length)
* $content_length - HTTP request body size
  ($http_content_length is not allowed by Rack)
* $content_type - HTTP request content type
  ($http_content_type is not allowed by Rack)
* $cookie_* - HTTP request cookie (e.g. $cookie_session_id)
  Rack::Request#cookies must have been used by the underlying application
  to parse the cookies into a hash.
* $request_method - the HTTP request method (e.g. GET, POST, HEAD, ...)
* $path_info - path component requested (e.g. /index.html)
* $query_string - request query string (not including leading "?")
* $request_uri - the URI requested ($path_info?$query_string)
* $request - the first line of the HTTP request
  ($request_method $request_uri $http_version)
* $request_time, $request_time{PRECISION} - time taken for request
  (including response body iteration).  PRECISION defaults to 3
  (milliseconds) if not specified but may be specified anywhere from
  0(seconds) to 6(microseconds).
* $time_local, $time_local{FORMAT} - current local time, FORMAT defaults to
  "%d/%b/%Y:%H:%M:%S %z" but accepts any strftime(3)-compatible format
* $time_utc, $time_utc{FORMAT} - like $time_local, except with UTC
* $usec - current time in seconds.microseconds since the Epoch
* $msec - current time in seconds.milliseconds since the Epoch
* $body_bytes_sent - bytes in the response body (Apache: %B)
* $response_length - body_bytes_sent, except "-" instead of "0" (Apache: %b)
* $remote_user - HTTP-authenticated user
* $remote_addr - IP of the requesting client socket
* $ip - X-Forwarded-For request header if available, $remote_addr if not
* $pid - process ID of the current process
* $e{Thread.current} - Thread processing the request
* $e{Actor.current} - Actor processing the request (Revactor or Rubinius)


* Ruby, Rack


The latest development happens in git and is published to the following:


You may also browse and download snapshot tarballs:

* (cgit)
* (gitweb)

The mailing list (see below) is central for coordination and
development.  Patches should always be sent inline
(git format-patch -M + git send-email) so we can reply to them inline.


All feedback (bug reports, user/development dicussion, patches, pull
requests) go to the mailing list.


Do not send HTML mail or attachments.  Do not top post.


For all Rubygems users:

  gem install clogger

If you're using MRI 1.8/1.9 and have a build environment, you can also try:

  gem install clogger_ext

If you do not use Rubygems, you may also use setup.rb from tarballs from
the Rubyforge project page:



Copyright (C) 2009 Eric Wong <> and contributors.

Clogger is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, version 3.0.

Clogger is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
License for more details.

You should have received a copy of the GNU Lesser General Public License
along with Clogger; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
2015-02-27 Eric Wongclogger 2.0.2 - bugfixes for pure Ruby usersmasterv2.0.2
2015-02-27 Eric Wongpure: use monotonic clock if possible
2015-02-27 Eric Wongpure: fix reentrancy of request_time
2015-01-13 Eric Wongclogger 2.0.1 - doc updates and new mailing listv2.0.1
2015-01-13 Eric Wongremove Rubyforge reference in Rakefile
2015-01-13 Eric Wonggemspec: use SPDX license abbreviation
2015-01-13 Eric Wongnew mailing list at
2015-01-13 Eric Wongext: get rid of noisy and unnecessary cast
2015-01-13 Eric Wongswitch docs + website to olddoc
2014-08-14 Eric WongREADME: document $env support for reading Rack env
2014-05-12 Eric Wongclogger 2.0.0 - updated website URL, cleanupsv2.0.0
2014-05-12 Eric Wongrelax license to allow LGPLv2.1 or later
2014-05-12 Eric Wongtest_clogger: workaround test failure on 32-bit
2014-05-12 Eric Wongremove :to_io support
2014-05-12 Eric Wongclogger 1.4.0 - updated website URL, cleanups
2014-05-12 Eric Wongupdate docs for rubyforge death
6 months ago v2.0.2 clogger 2.0.2 - bugfixes for pure...
7 months ago v2.0.1 clogger 2.0.1 - doc updates and...
15 months ago v2.0.0 clogger 2.0.0 - updated website...
23 months ago v1.3.0 clogger 1.3.0 - avoid RARRAY_PTR...
2 years ago v1.2.0 clogger 1.2.0 - small bug and compa...
3 years ago v1.1.0 clogger 1.1.0 - more escaping!
4 years ago v1.0.1 clogger 1.0.1 - portability fixes
4 years ago v1.0.0 clogger 1.0.0 - \o/
4 years ago v0.9.0 clogger 0.9.0 - configurable loggin...
4 years ago v0.8.0 clogger 0.8.0 - delegating away!
4 years ago v0.7.0 clogger 0.7.0 - portability improve...
4 years ago v0.6.0 clogger 0.6.0 - :path shortcut...
5 years ago v0.5.0 clogger 0.5.0 - body.to_path forwarding
5 years ago v0.4.0 clogger 0.4.0
5 years ago v0.3.2 clogger 0.3.2
5 years ago v0.3.1 clogger 0.3.1
6 months ago master