Reputation: 986
How frequently nginx flushes its buffer to access_log by default ?
In manual there is not info, just setup syntax:
access_log path [format [buffer=size [flush=time]] [if=condition]];
Upvotes: 10
Views: 11191
Reputation: 7150
Nginx doesn't flush unless you specify the flush
option (even if you have specified the buffer
option).
Here's an example of how to buffer packets of 8k to the log every five minutes:
access_log /var/log/nginx/access.log main buffer=8k flush=5m;
Upvotes: 7
Reputation: 999
From the nginx documentation [1]:
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, 1.2.7);
- when a worker process is re-opening log files or is shutting down.
Of course if you do not specify the flush
parameter the second condition can not become true.
[1] http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
Upvotes: 0
Reputation: 72560
Did a bit of research on this myself, and as far as I can tell nginx doesn't flush buffers at all if you do not specify the flush parameter. (Or if it does, it's more than 20 minutes.)
The only exception is if you restart the server, the logs are flushed before restart.
So if you specify the buffer you should make sure to specify the flush time too.
Upvotes: 2