# HG changeset patch # User Valentin Bartenev # Date 1356449004 0 # Node ID 41363f013cc93d9b4fa953fc4adb37ff9e87cba6 # Parent e77512b1ce11d4a57b5ca622b886b467e30ea5a3 Documented the recently added "gzip" and "flush" parameters of the "access_log" directive. diff --git a/xml/en/docs/http/ngx_http_log_module.xml b/xml/en/docs/http/ngx_http_log_module.xml --- a/xml/en/docs/http/ngx_http_log_module.xml +++ b/xml/en/docs/http/ngx_http_log_module.xml @@ -10,7 +10,7 @@ + rev="7">
@@ -33,11 +33,11 @@ redirect happens during request p -log_format gzip '$remote_addr - $remote_user [$time_local] ' - '"$request" $status $bytes_sent ' - '"$http_referer" "$http_user_agent" "$gzip_ratio"'; +log_format compression '$remote_addr - $remote_user [$time_local] ' + '"$request" $status $bytes_sent ' + '"$http_referer" "$http_user_agent" "$gzip_ratio"'; -access_log /spool/logs/nginx-access.log gzip buffer=32k; +access_log /spool/logs/nginx-access.log compression buffer=32k; @@ -50,7 +50,14 @@ access_log /spool/logs/nginx-access.log path [format - [buffer=size]] + [buffer=size + [flush=time]]] + + path + format + gzip[=level] + [buffer=size] + [flush=time] off logs/access.log combined http @@ -60,7 +67,7 @@ access_log /spool/logs/nginx-access.log limit_except -Sets the path, format, and buffer size for the buffered log writes. +Sets the path, format, and configuration of the buffered log writes. Several logs can be specified on the same level. The special value off cancels all access_log directives on the current level. @@ -69,8 +76,57 @@ If format is not specified then the pred +If either the buffer or gzip (1.3.10) +parameter is used, writes to log will be buffered. + The buffer size must not exceed the size of the 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 specified by the flush +parameter (1.3.10); + + + +when a worker process is re-opening log +files or is shutting down. + + + + + + +If the gzip parameter is used, then the buffered data will +be compressed before writing to the file. +The compression level can be set between 1 (fastest, less compression) +and 9 (slowest, best compression). +By default the buffer size is equal to 64K bytes, and the compression level +is set to 1. +Since the data is compressed in atomic blocks, the log file can be decompressed +or read by “zcat” at any time. + + + +Example: + +access_log /path/to/log.gz combined gzip flush=5m; + + + + + +For gzip compression to work, nginx must be built with the zlib library. + diff --git a/xml/ru/docs/http/ngx_http_log_module.xml b/xml/ru/docs/http/ngx_http_log_module.xml --- a/xml/ru/docs/http/ngx_http_log_module.xml +++ b/xml/ru/docs/http/ngx_http_log_module.xml @@ -10,7 +10,7 @@ + rev="7">
@@ -34,11 +34,11 @@ -log_format gzip '$remote_addr - $remote_user [$time_local] ' - '"$request" $status $bytes_sent ' - '"$http_referer" "$http_user_agent" "$gzip_ratio"'; +log_format compression '$remote_addr - $remote_user [$time_local] ' + '"$request" $status $bytes_sent ' + '"$http_referer" "$http_user_agent" "$gzip_ratio"'; -access_log /spool/logs/nginx-access.log gzip buffer=32k; +access_log /spool/logs/nginx-access.log compression buffer=32k; @@ -51,7 +51,14 @@ access_log /spool/logs/nginx-access.log путь [формат - [buffer=размер]] + [buffer=размер + [flush=время]]] + + путь + формат + gzip[=степень] + [buffer=размер] + [flush=время] off logs/access.log combined http @@ -61,7 +68,7 @@ access_log /spool/logs/nginx-access.log limit_except -Задаёт путь, формат и размер буфера для буферизованной записи в лог. +Задаёт путь, формат и настройки буферизованной записи в лог. На одном уровне может использоваться несколько логов. Специальное значение off отменяет все директивы access_log для текущего уровня. @@ -70,8 +77,57 @@ access_log /spool/logs/nginx-access.log +Если задан размер буфера с помощью параметра buffer или +указан параметр gzip (1.3.10), то запись будет +буферизованной. + Размер буфера должен быть не больше размера атомарной записи в дисковый файл. Для FreeBSD этот размер неограничен. + + + + +При включённой буферизации данные записываются в файл: + + + +если очередная строка лога не помещается в буфер; + + + +если данные в буфере находятся дольше интервала времени, заданного +параметром flush (1.3.10); + + + +при переоткрытии лог-файла или +завершении рабочего процесса. + + + + + + +Если задан параметр gzip, то буфер будет сжиматься перед +записью в файл. +Степень сжатия может быть задана в диапазоне от 1 (быстрее, но хуже сжатие) +до 9 (медленнее, но лучше сжатие). +По умолчанию используется буфер размером 64К байт и степень сжатия 1. +Данные сжимаются атомарными блоками, и в любой момент времени лог-файл может +быть распакован или прочитан с помощью утилиты “zcat”. + + + +Пример: + +access_log /path/to/log.gz combined gzip flush=5m; + + + + + +Для поддержки gzip-сжатия логов nginx должен быть собран с библиотекой zlib. +