AccessLog provides logging to various files in various formats.

Multiple logs may be written to at the same time:

access_log = [
  [$stderr, WEBrick::AccessLog::COMMON_LOG_FORMAT],
  [$stderr, WEBrick::AccessLog::REFERER_LOG_FORMAT],
]

server = WEBrick::HTTPServer.new :AccessLog => access_log

Custom log formats may be defined. WEBrick::AccessLog provides a subset of the formatting from Apache’s mod_log_config httpd.apache.org/docs/mod/mod_log_config.html#formats. See AccessLog::setup_params for a list of supported options

Constants

The Common Log Format’s time format

Common Log Format

CLF

Short alias for Common Log Format

Referer Log Format

User-Agent Log Format

Combined Log Format

Instance Methods

Escapes control characters in data

Formats params according to format_string which is described in setup_params.

This format specification is a subset of mod_log_config of Apache:

%a

Remote IP address

%b

Total response size

%e{variable}

Given variable in ENV

%f

Response filename

%h

Remote host name

%{header}i

Given request header

%l

Remote logname, always “-”

%m

Request method

%{attr}n

Given request attribute from req.attributes

%{header}o

Given response header

%p

Server’s request port

%{format}p

The canonical port of the server serving the request or the actual port or the client’s actual port. Valid formats are canonical, local or remote.

%q

Request query string

%r

First line of the request

%s

Request status

%t

Time the request was received

%T

Time taken to process the request

%u

Remote user from auth

%U

Unparsed URI

%%

Literal %