Default boot time Nginx access_log

How often does nginx by default delete its buffer in access_log?

There is no information in the manual, just set the syntax:

access_log path [format [buffer=size [flush=time]] [if=condition]]; 
+6
source share
3 answers

I examined this myself a bit, and as far as I can tell, nginx does not flush buffers at all unless you specify the flush parameter. (Or, if so, it is over 20 minutes.)

The only exception is if you reboot the server, the logs are rebooted before rebooting.

Therefore, if you specify a buffer, you must also specify a cleanup time.

+2
source

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 cannot become true.

[1] http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log

0
source

It is not reset unless you specify the flush option (even if you specified the buffer option).

Here is an example of how to buffer packets from log to log every 5 minutes:

 access_log /var/log/nginx/access.log main buffer=8k flush=5m; 
0
source

All Articles