| Did you know ... | Search Documentation: |
| Packs (add-ons) for SWI-Prolog |
| Title: | Analyse SWI-Prolog HTTP server log files |
|---|---|
| Rating: | Not rated. Create the first rating! |
| Latest version: | 0.5.0 |
| SHA1 sum: | 38b45e88420de53da41854e1e6ed9aa6159713aa |
| Author: | Jan Wielemaker <jan@swi-prolog.org> |
| Home page: | https://github.com/JanWielemaker/httplog |
| Download URL: | https://github.com/JanWielemaker/httplog/archive/*.zip |
No reviews. Create the first review!.
| Version | SHA1 | #Downloads | URL |
|---|---|---|---|
| 0.5.0 | 38b45e88420de53da41854e1e6ed9aa6159713aa | 3 | https://github.com/JanWielemaker/httplog/archive/V0.5.0.zip |
| 1aed696cbefd00c4a2a4f618f89d0096299ebd14 | 25 | https://github.com/JanWielemaker/httplog/archive/V0.5.0.zip |
The SWI-Prolog HTTP server can be asked to write a logfile by loading the library(http/http_log). The resulting file is a file holding Prolog terms. This package allows for loading the logfile into the Prolog database and ask queries about it.
Before you can analyse a logfile it must be read into the Prolog
database. Assuming the default name httpd.log, this is achieved using
the following command:
% swipl
?- use_module(library(http/logstat)).
?- read_log('httpd.log').
In the examples below, we assume a logfile as created by ClioPatria. Adjust the paths and query parameter to match your web server. Once loaded, the database can be queried using logrecord/1. A simple example is:
?- logrecord([path('/sparql/'), search([query=Query])]).
Suppose you want to make a CSV file holding the IP addresses and the search executed from there. This can be achieved using:
?- findall(row(IP,Q),
logrecord([path('/browse/search'), search([q=Q]), ip(IP)]),
Rows),
csv_write_file('queries.csv', Rows).
The Prolog script file script/log2clf.pl can be used to convert SWI-Prolog logfiles into the webserver Common Log Format syntax, so you can run common tools such as webalizer on them. This script is executed as:
% log2clf [-o out] [-a date] [-b date] file ...
Pack contains 4 files holding a total of 16.9K bytes.