# Clogger 0.0.1

**URL:** <https://www.ruby-forum.com/t/clogger-0-0-1/174586>\
**Category:** Ruby\
**Created:** [August 29, 2009, 7:27am UTC](https://www.ruby-forum.com/t/clogger-0-0-1/174586 "2009-08-29T07:27:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/97f17d/32.png) [@ericw](https://www.ruby-forum.com/u/ericw)\
**Post date:** [August 29, 2009, 7:27am UTC](https://www.ruby-forum.com/t/clogger-0-0-1/174586/1 "2009-08-29T07:27:46Z")

</div>

= Clogger - configurable request logging for Rack

- [http://clogger.rubyforge.org/](http://clogger.rubyforge.org/)
- [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

== DESCRIPTION

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

== FEATURES

- 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.

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

== SYNOPSIS

Clogger may be loaded as Rack middleware in your [config.ru](http://config.ru):

require “clogger”  
use Clogger,  
:format =\> Clogger::Format::Combined,  
:logger =\> File.open(“/path/to/log”, “ab”)  
run YourApplication.new

If you’re using Rails 2.3.x or later, in your config/environment.rb  
somewhere inside the “Rails::Initializer.run do |config|” block:

config.middleware.use ‘Clogger’,  
:format =\> Clogger::Format::Combined,  
:logger =\> File.open(“/path/to/log”, “ab”)

== VARIABLES

- $http\_\* - HTTP request headers (e.g. $http\_user\_agent)
- $sent\_http\_\* - HTTP response headers (e.g. $sent\_http\_content\_length)
- $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 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)

== REQUIREMENTS

- Ruby, Rack

== DEVELOPMENT

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

git://rubyforge.org/clogger.git  
git://git.bogomips.org/mirrors/clogger.git

You may also browse and download snapshot tarballs:

- [http://clogger.rubyforge.org/git?p=clogger.git](http://clogger.rubyforge.org/git?p=clogger.git) (gitweb)
- [http://git.bogomips.org/cgit/mirrors/clogger.git](http://git.bogomips.org/cgit/mirrors/clogger.git) (cgit)

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.

== CONTACT

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

- [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

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

== INSTALL

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:

- [http://rubyforge.org/frs/?group\_id=8896](http://rubyforge.org/frs/?group_id=8896)

== LICENSE

Copyright (C) 2009 Eric W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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  
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public  
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
