Nginx logs per seconds

maorbari

Verified User
Joined
Nov 8, 2013
Messages
21
Hi,
I get flood of logs in nginx.
How I can do that the logs will be save in memory for one second and than write it from memory to logs files per second and not any query?
I mean log all in memory and output to log it one per second.
Thanks.
 
Hello,

You can enable buffering for access logs:

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.
related: http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log


and disable logging of errors about not found files into error_log:

Code:
log_not_found on;
http://nginx.org/en/docs/http/ngx_http_core_module.html#log_not_found
 
Hello,

You can enable buffering for access logs:

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.
related: http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log


and disable logging of errors about not found files into error_log:

Code:
log_not_found on;
http://nginx.org/en/docs/http/ngx_http_core_module.html#log_not_found
Thanks..
But with buffer it do it only once.. and than it continue to write like before..
Another idea?
 
Two more options:

1. completely disable logging in nginx
2. in case you've got enough RAM mount /var/log/nginx/ as tmpfs.
 
Back
Top