Rails request log

depquid edited this page Apr 23, 2014 · 7 revisions

The Rails request log is the default file format for request-log-analyzer.

Note: these docs are mostly geared towards Rails 2 log files. For Rails3, use --format rails3.

Specifying log lines to parse

For Rails 2 logs, the --rails-format <format identifier> command line option can be used to specify what lines should be parsed. The less line types are considered, the faster the parsing will be. On the other hand, the report will be sparser because there will be less information available.

Common sets of line to parse

Set name Explanation
minimal Only parse the “Processing …” and “Completed in …” lines
production Parse exceptions and cache hit lines besides the minimal lines
development Parse exceptions, SQL queries, partial renderings besides the minimal lines
all Parse every supported line type (see below)

If no --rails-format command line option is given, the parser will use the production set of lines.

All parsable lines

You can also specify the lines to parse yourself using a comma separated list. You can also include set names as mentioned above in this list, e.g.: --rails-format minimal,failure,rendered. The following lines types are supported:

Line type Explanation
processing The header line of each request in your log
completed The footer line of each request in your log
failure The line that shows up when an (unhandled) exception occurs.
cache_hit Occurs when a request is served from the action cache
parameters The line with all the request parameters
rendered A rendered partial (by default, occurs only in the development log)
query_executed An executed SQL query (by default, occurs only in the development log)
query_cached An executed SQL query (by default, occurs only in the development log)

Note that you should specify at least a header line and a footer line so r-l-a knows when a new requests starts in your log. Therefore, you should always include processing and completed (= minimal) in your line list.

Minimum logger level

RLA requires a minimum log level of :info. Log levels greater than :info do not write request metrics to the log file.

Configuring the logger

To get the best results out of the Rails format parser, logging must be set up correctly. See Configure logging for more information on tuning the Rails logger.