README: document CLOGGER_PURE environment variable
[clogger.git] / README
blobc2f5155875538fe3c4bcf0b602062dbe1ce7fbf4
1 = \Clogger - configurable request logging for Rack
3 == DESCRIPTION
5 \Clogger is Rack middleware for logging HTTP requests.  The log format
6 is customizable so you can specify exactly which fields to log.
8 == FEATURES
10 * highly customizable with easy-to-read nginx-like log format variables.
12 * pre-defines Apache Common Log Format, Apache Combined Log Format and
13   Rack::CommonLogger (as distributed by Rack 1.0) formats.
14   See Clogger::Format for the predefined formats.
16 * Untrusted values are escaped (all HTTP headers, request URI components)
17   to make life easier for HTTP log parsers. The following bytes are escaped:
19     ' (single quote)
20     " (double quote)
21     all bytes in the range of \x00-\x1F
23 * multi-instance capable and (optionally) reentrant.  You can use
24   \Clogger in a multi-threaded server, and even multiple Cloggers logging
25   to different locations and different formats in the same process.
27 * Pure Ruby version for non-MRI versions of Ruby (or via CLOGGER_PURE=1
28   in the environment).  The optional C extension is loaded by default
29   and supported under MRI 1.8.7, 1.9.1, and 1.9.2.
31 == SYNOPSIS
33 \Clogger may be loaded as Rack middleware in your config.ru:
35   # ENV['CLOGGER_PURE'] = '1' # uncomment to disable C extension
36   require "clogger"
37   use Clogger,
38       :format => Clogger::Format::Combined,
39       :logger => ::File.open("/path/to/log", "ab"),
40       :reentrant => true
41   run YourApplication.new
43 If you're using Rails 2.3.x or later, in your config/environment.rb
44 somewhere inside the "Rails::Initializer.run do |config|" block:
46   config.middleware.use 'Clogger',
47       :format => Clogger::Format::Combined,
48       :logger => ::File.open("/path/to/log", "ab"),
49       :reentrant => false
51 == VARIABLES
53 * $http_* - HTTP request headers (e.g. $http_user_agent)
54 * $sent_http_* - HTTP response headers (e.g. $sent_http_content_length)
55 * $content_length - HTTP request body size
56   ($http_content_length is not allowed by Rack)
57 * $content_type - HTTP request content type
58   ($http_content_type is not allowed by Rack)
59 * $cookie_* - HTTP request cookie (e.g. $cookie_session_id)
60   Rack::Request#cookies must have been used by the underlying application
61   to parse the cookies into a hash.
62 * $request_method - the HTTP request method (e.g. GET, POST, HEAD, ...)
63 * $path_info - path component requested (e.g. /index.html)
64 * $query_string - request query string (not including leading "?")
65 * $request_uri - the URI requested ($path_info?$query_string)
66 * $request - the first line of the HTTP request
67   ($request_method $request_uri $http_version)
68 * $request_time, $request_time{PRECISION} - time taken for request
69   (including response body iteration).  PRECISION defaults to 3
70   (milliseconds) if not specified but may be specified anywhere from
71   0(seconds) to 6(microseconds).
72 * $time_local, $time_local{FORMAT} - current local time, FORMAT defaults to
73   "%d/%b/%Y:%H:%M:%S %z" but accepts any strftime(3)-compatible format
74 * $time_utc, $time_utc{FORMAT} - like $time_local, except with UTC
75 * $usec - current time in seconds.microseconds since the Epoch
76 * $msec - current time in seconds.milliseconds since the Epoch
77 * $body_bytes_sent - bytes in the response body (Apache: %B)
78 * $response_length - body_bytes_sent, except "-" instead of "0" (Apache: %b)
79 * $remote_user - HTTP-authenticated user
80 * $remote_addr - IP of the requesting client socket
81 * $status - three-digit HTTP status code (e.g. 200, 404, 302)
82 * $ip - X-Forwarded-For request header if available, $remote_addr if not
83 * $pid - process ID of the current process
84 * $e{Thread.current} - Thread processing the request
85 * $e{Actor.current} - Actor processing the request (Revactor or Rubinius)
87 == REQUIREMENTS
89 * {Ruby}[http://ruby-lang.org/], {Rack}[http://rack.rubyforge.org/]
91 == DEVELOPMENT
93 The latest development happens in git and is published to the following:
95    git://git.bogomips.org/clogger.git
96    git://repo.or.cz/clogger.git
98 You may also browse and download snapshot tarballs:
100 * http://git.bogomips.org/cgit/clogger.git (cgit)
101 * http://repo.or.cz/w/clogger.git (gitweb)
103 The mailing list (see below) is central for coordination and
104 development.  Patches should always be sent inline
105 (git format-patch -M + git send-email) so we can reply to them inline.
107 == CONTACT
109 All feedback (bug reports, user/development dicussion, patches, pull
110 requests) go to the mailing list.
112 * mailto:clogger@librelist.com
114 Do not send HTML mail or attachments.  Do not top post.
116 Homepage: http://clogger.rubyforge.org/
118 == INSTALL
120 For Rubygems users:
122   gem install clogger
124 If you do not use Rubygems, you may also use setup.rb from the tarballs
125 on the Rubyforge project page:
127 * http://rubyforge.org/frs/?group_id=8896
129 There is an optional C extension that should be compatible with MRI
130 1.8/1.9.  The extensions should automatically be disabled for users of
131 other Ruby implementations, but be sure to let us know if that's not the
132 case.  No pre-built binaries are currently distributed, let us know if
133 you're interested in helping with the release/support effort.