Did you know ... Search Documentation:
Pack httplog -- prolog/http/logstat.pl
PublicShow source

This module reads SWI-Prolog HTTPD logfiles and allows asking queries about them. Below is a simple example that extracts SPARQL queries from a ClioPatria log file:

?- use_module(library(http/logstat)).
?- read_log('httpd.log').
?- logrecord([path('/sparql/'), search([query=Query])]).
Query = 'PREFIX rdf: ...'
See also
- library(http/http_log) provides the HTTP framework component to write logfiles that are expected by this library.
 logrecord(?N, ?Time, ?Session, ?RemoteIP, ?Path, ?Query, ?Referrer, ?Code, ?Result, ?Extra)
Database predicate that represents an HTTP transaction.
Arguments:
N- is the index number of the record
Time- is the POSIX time stamp the query was fired
Session- is the session-id or - if the request has no session
RemoteIP- is the remote IP address
Path- is the HTTP location, starting with /
Query- is a list of Name=Value terms holding the (GET) query parameters
Referrer- is the referer URL or - if unknown
Code- is the HTTP numerical reply code
Result- is Prolog notion of the result as a Prolog term
Extra- is a list with Key(Value) terms holding the keys below. Only cpu(Seconds) is always present.
cpu(Seconds)
CPU time used to process the query
bytes(Count)
Number of bytes sent (if known)
user_agent(UserAgent)
Browser identifier (if known)
http_version(Major-Minor)
HTTP Protocol version
city(City)
Name of the city (if configured)
lat(Lat)
Latitude (if configured)
lon(Lon)
Longitude (if configured)
 clean_log
Cleanup the database.
 read_log(+File) is det
 read_log(+File, +Options) is det
Read a SWI-Prolog HTTP logfile. If the file contains errors, these are printed to the terminal and the corresponding records are ignored. Options supported:
progress(+Boolean)
Indicate progress on the terminal (default true)
skip_bad_requests(+Boolean)
Ignore 400 requests.
 logrecord(+Query) is nondet
Query by list of fieldnames. Query list a list of Name(Value) specifications. Name is one of:
key(Integer)
Integer number of the request (1,2,3,...)
time(Float)
POSIX time stamp of the request.
session(Atom)
The session-id or - if the request has no session
ip(Atom)
The remote IP address
path(Atom)
The HTTP location, starting with /
query(list(Name=Value))
List of Name=Value terms holding the (GET) query parameters
referer(Atom)
The referer URL or - if unknown
code(Integer)
Code is the HTTP numerical reply code
result(Term)
Prolog notion of the result as a Prolog term
cpu(Seconds)
CPU time used to process the query
bytes(Count)
Number of bytes sent (if known)
user_agent(UserAgent)
Browser identifier (if known)
http_version(Major-Minor)
HTTP Protocol version
city(City)
Name of the city (if configured)
lat(Lat)
Latitude (if configured)
lon(Lon)
Longitude (if configured)
after(+TimeSpec)
Only consider records created after TimeSpec. TimeSpec is one of:
  • Year/Month/Day
before(+TimeSpec)
See after(TimeSpec).
search([...(Name=Value)])
Demand the following fields to be present in the query.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 read_log(Arg1, Arg2)