
http_log.pl -- HTTP Logging module
Simple module for logging HTTP requests to a file. Logging is enabled by
loading this file and ensure the setting http:logfile is not the empty
atom. The default file for writing the log is httpd.log. See
library(settings) for details.
The level of logging can be modified using the multifile predicate
http_log:nolog/1 to hide HTTP request fields from the logfile and
http_log:password_field/1 to hide passwords from HTTP search
specifications (e.g. /topsecret?password=secret).
http_log_stream(-Stream) is semidetappend mode if the file is not yet open. The log file
is determined from the setting http:logfile. If this setting is
set to the empty atom (''), this predicate fails.
If a file error is encountered, this is reported using print_message/2, after which this predicate silently fails. Opening is retried every minute when a new message arrives.
Before opening the log file, the message http_log_open(Term) is
broadcasted. This message allows for creating the directory,
renaming, deleting or truncating an existing log file.
http_log_close(+Reason) is detserver(Reason, Time). to the logfile. This call is
intended for cooperation with the Unix logrotate facility
using the following schema:
http_log(+Format, +Args) is det
password_field(+Field) is semidet[multifile]
nolog(+HTTPField)[multifile]
nolog_post_content_type(+Type) is semidet[multifile]Content-type header. If the
hook succeeds, the POST data is not logged. For example, to stop
logging anything but application/json messages:
:- multifile http_log:nolog_post_content_type/1. http_log:nolog_post_content_type(Type) :- Type \= (application/json).
post_data_encoded(?Bytes:string, ?Encoded:string) is det
http_logrotate(+Options) is detOptions:
true, rotate the log files in the background.
http_schedule_logrotate(When, Options)
This must be used with a timer that broadcasts a
maintenance(_,_) message (see broadcast/1). Such a timer is part
of library(http/http_unix_daemon).