httpd::log(n) 1.1 "Tcl Web Server"

Name

httpd::log - Logging of web activity

Table Of Contents

Synopsis

Description

The package httpd::log is a core module providing all other modules of the web server with commands to log user activity.

This package has a soft-dependency on the package httpd::counter. The command Log_SetFile will use Counter_Checkpoint to save the counter state as part of flushing the logs to disk, but only if the httpd::counter package is present.

Public API

Log sock reason arg...

Log information about the activity of the web server. There are two kinds of log entries. One normal entry that goes into its own log, one line for each HTTP transaction. All other log records are appended to an error log file.

The first argument, sock provides the handle of the connection causing the generation of this entry. If the reason is set to Close then this is the normal completion of a request. Otherwise, this is some error tag and the record goes to the error log.

The other arguments are copied verbatim into the log file chosen for the entry.

Log_Configure
Log_Configure option
Log_Configure (option value)...

(Re)configures the package, or retrieves the configuration.

When called without arguments the current configuration is returned as a dictionary. When called with a single argument the current value of that option is returned. Else the package is reconfigured using the specificed options and values.

The accepted options are

-lognames

The argument is a boolean value. If set to true the package log::std will log the domain names of the hosts acessing the web server. The default is false as the DNS lookup is a time-expensive operation, causing the logging of the bare ip-addresses instead.

Log_FlushMinutes min

Sets the interval in minutes at which the logs are flushed to disk. If the interval is set to 0 then the logs will be flushed on each write. The default is one minute.

Log_SetFile ?basename?

The command is multi-purpose. Calling it sets a new basename for the two log files. It flushes all logs, rotates the old log files and swaps in the new. It also sets up a timer event which will perform the same rotation at the next midnight.

When called without argument it performs all of the operations above, except that the basename for the log files is not changed. This is the way the timer event above is set up.

The above means that this command should be used once, during the startup of the web server to define a log file and initiate the logging. From then on the system will automatically rotate the created logs every midnight without user intervention.

Log_Flush

Calling this command causes the package to periodically flush the log files to disk, according to the interval set via Log_FlushMinutes.

See Also

httpd, httpd::counter, httpd::logstd

Keywords

log, trace, web server