Log#
The module writes request logs in the specified format. Default stream, server Sets the path, format, and configuration for a buffered log write. Several logs can be specified on the same configuration level. Logging to syslog can be configured by specifying the "syslog:" prefix in the first parameter. The special value off cancels all access_log directives on the current level. Enables buffered writing with a buffer of the specified size. Enables buffered writing and compresses the buffer before writing it to
the file. The compression level can be set between Sets the maximum time data can stay in the buffer before it is written to the file;
requires a buffer set with Enables conditional logging: a session is not logged
if the condition evaluates to "0" or an empty string. Warning The buffer size must not exceed the size of an atomic write to a disk file. For FreeBSD this size is unlimited. When buffering is enabled, the data will be written to the file: if the next log line does not fit into the buffer; if the buffered data is older than the time interval specified by the when a worker process is re-opening log files or is shutting down. Example: Note For gzip compression support, Angie must be built with the zlib library. The file path can contain variables, but such logs have some constraints: the user whose credentials are used by worker processes should have permissions to create files in a directory with such logs; buffering does not work; the file is opened for each log write and closed immediately after writing. However, since descriptors of frequently used files can be stored in a cache, writing may continue to the old file during log rotation for the time specified by the valid parameter of the open_log_file_cache directive. Specifies the log format, for example: Sets character escaping in variables to When using When using Default stream, server Defines a cache that stores the file descriptors of frequently used logs whose names contain variables; the Sets the maximum number of descriptors in the cache; when the cache overflows, the least recently used (LRU) descriptors are closed. Sets the time after which a cached descriptor is closed if there were no accesses during this time; by default, 10 seconds. Sets the minimum number of file uses during the time defined by the Sets the time after which it should be checked that the file still exists with the same name; by default, 60 seconds. Usage example:Configuration Example#
log_format basic '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time';
access_log /spool/logs/angie-access.log basic buffer=32k;
Directives#
access_log#
access_log path [format [buffer=size] [gzip[=level]] [flush=time] [if=condition]];access_log off;access_log off;buffer=sizegzip[=level]1 (fastest,
less compression) and 9 (slowest, best compression). By default,
a buffer size of 64K bytes and compression level 1 are
used. The data is compressed in atomic blocks, and at any time the log
file can be decompressed or read by the "zcat" utility.flush=timebuffer= or gzip.if=conditionflush parameter;access_log /path/to/log.gz basic gzip flush=5m;
log_format#
log_format proxy '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" '
'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
escape=default | json | nonejson or default; by default, default is used. The none value disables character escaping.default, characters """, "\", and characters with values less than 32 or greater than 126 are escaped as "\xXX". If the variable value is not found, a hyphen "-" will be logged.json, all characters not allowed in JSON strings are escaped: characters """ and "\" are escaped as "\"" and "\\", characters with values less than 32 are escaped as "\n", "\r", "\t", "\b", "\f", or "\u00XX".open_log_file_cache#
open_log_file_cache max=N [inactive=time] [min_uses=N] [valid=time];open_log_file_cache off;open_log_file_cache off;off value disables caching. The directive has the following parameters:max=Ninactive=timemin_uses=Ninactive parameter for the descriptor to remain open in the cache; by default, 1.valid=timeopen_log_file_cache max=1000 inactive=20s valid=1m min_uses=2;