Pipe apache logs into readlog
to selectively display interesting information.
Example: show the access time as Unix epoch and ip addresses
cat /var/log/apache2/access.log | ./readlog --columns=time,ips
Python 2.5 or later is required. The ApacheReader
extension is required and
can be compiled and installed by running:
python setup.py install
readlog offers 4 command line options:
--columns
- comma delimited list of column names--params
- comma delimited list of query parameter names--date
- output date format pattern, default is Unix epoch--format
- log format pattern, default iscommon
The available column names, see http://httpd.apache.org/docs/2.2/logs.html#accesslog for details
ips
- IP address of the client (remote host)username
- userid by HTTP authentication.ident
- identitytime
- time that the request was receivedtz
- timezonemethod
- method used by the clienturl
- requested urlpath
- hierarchical path in the urlquery
- query component in the urlfragment
- fragment identifier in the urlprotocol
- protocol used by the clientstatus
- status code that the server sends back to the clientsize
- size of the object returned to the clientreferer
- the site that the client reports having been referred fromuser-agent
- User-Agent HTTP request header
The names in the --params
option can be used to show the corresponding query
parameter values.
Example: show the query parameter values with names equal to page
and type
cat /var/log/apache2/access.log | ./readlog --params=page,type
The options --params
and --columns
can be combined.
The --date
option defines the date format for the time
column. For format
patterns see:
http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior
The --format
option defines the log input format, in particular, common
and
combined
corresponds to the apache common and combined log formats. A custom
input log format is supported by specifying the pattern string as argument.
See http://httpd.apache.org/docs/2.2/logs.html#accesslog for details.
This package uses the ApacheReader
extension from http://github.com/idealisms/apache-log-reader