fix #include ordering under FreeBSD 7.2
[clogger.git] / README
blobc61e0da5f7df3ec3e3dfe6c02a7ef53b48ed7625
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 and 1.1) 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       :path => "/path/to/log",
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       :path => "/path/to/log",
49       :reentrant => false
51 Instead of specifying a :path, you may also specify a :logger object
52 that receives a "<<" method:
54   use Clogger, :logger=> $stdout, :reentrant => true
55   run YourApplication.new
57 == VARIABLES
59 * $http_* - HTTP request headers (e.g. $http_user_agent)
60 * $sent_http_* - HTTP response headers (e.g. $sent_http_content_length)
61 * $content_length - HTTP request body size
62   ($http_content_length is not allowed by Rack)
63 * $content_type - HTTP request content type
64   ($http_content_type is not allowed by Rack)
65 * $cookie_* - HTTP request cookie (e.g. $cookie_session_id)
66   Rack::Request#cookies must have been used by the underlying application
67   to parse the cookies into a hash.
68 * $request_method - the HTTP request method (e.g. GET, POST, HEAD, ...)
69 * $path_info - path component requested (e.g. /index.html)
70 * $query_string - request query string (not including leading "?")
71 * $request_uri - the URI requested ($path_info?$query_string)
72 * $request - the first line of the HTTP request
73   ($request_method $request_uri $http_version)
74 * $request_time, $request_time{PRECISION} - time taken for request
75   (including response body iteration).  PRECISION defaults to 3
76   (milliseconds) if not specified but may be specified anywhere from
77   0(seconds) to 6(microseconds).
78 * $time_local, $time_local{FORMAT} - current local time, FORMAT defaults to
79   "%d/%b/%Y:%H:%M:%S %z" but accepts any strftime(3)-compatible format
80 * $time_utc, $time_utc{FORMAT} - like $time_local, except with UTC
81 * $usec - current time in seconds.microseconds since the Epoch
82 * $msec - current time in seconds.milliseconds since the Epoch
83 * $body_bytes_sent - bytes in the response body (Apache: %B)
84 * $response_length - body_bytes_sent, except "-" instead of "0" (Apache: %b)
85 * $remote_user - HTTP-authenticated user
86 * $remote_addr - IP of the requesting client socket
87 * $status - three-digit HTTP status code (e.g. 200, 404, 302)
88 * $ip - X-Forwarded-For request header if available, $remote_addr if not
89 * $pid - process ID of the current process
90 * $e{Thread.current} - Thread processing the request
91 * $e{Actor.current} - Actor processing the request (Revactor or Rubinius)
93 == REQUIREMENTS
95 * {Ruby}[http://ruby-lang.org/], {Rack}[http://rack.rubyforge.org/]
97 == DEVELOPMENT
99 The latest development happens in git and is published to the following:
101    git://git.bogomips.org/clogger.git
102    git://repo.or.cz/clogger.git
104 You may also browse and download snapshot tarballs:
106 * http://git.bogomips.org/cgit/clogger.git (cgit)
107 * http://repo.or.cz/w/clogger.git (gitweb)
109 The mailing list (see below) is central for coordination and
110 development.  Patches should always be sent inline
111 (git format-patch -M + git send-email) so we can reply to them inline.
113 == CONTACT
115 All feedback (bug reports, user/development dicussion, patches, pull
116 requests) go to the mailing list.
118 * mailto:clogger@librelist.com
120 Do not send HTML mail or attachments.  Do not top post.
122 Homepage: http://clogger.rubyforge.org/
124 == INSTALL
126 For Rubygems users:
128   gem install clogger
130 If you do not use Rubygems, you may also use setup.rb from the tarballs
131 on the Rubyforge project page:
133 * http://rubyforge.org/frs/?group_id=8896
135 There is an optional C extension that should be compatible with MRI
136 1.8/1.9.  The extensions should automatically be disabled for users of
137 other Ruby implementations, but be sure to let us know if that's not the
138 case.  No pre-built binaries are currently distributed, let us know if
139 you're interested in helping with the release/support effort.