diff src/core/ngx_connection.c @ 9225:1c9264603adc

Syslog: introduced ngx_syslog_send() error logging moderation. Errors when logging to syslog are now logged at most once per second. This ensures that persistent errors won't flood other logs, and spontaneous errors, such as ENOBUFS as observed on BSD systems when syslogd cannot cope with load, or EAGAIN as seen in similar situation on Linux, won't further overload logging subsystem, leading to more errors. Further, errors now can only trigger reconnects at most once per second. This ensures that persistent errors, which cannot be fixed with reconnects, don't trigger too much unneeded work. Additionally, in case of connection errors, such as when syslogd is not running, connection attempts are only made once per second.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 01 Mar 2024 05:42:12 +0300
parents 58afcd72446f
children 37ef53ecd6b0
line wrap: on
line diff
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -1604,6 +1604,10 @@ ngx_connection_error(ngx_connection_t *c
     {
         switch (c->log_error) {
 
+        case NGX_ERROR_DEBUG:
+            level = NGX_LOG_DEBUG;
+            break;
+
         case NGX_ERROR_IGNORE_EMSGSIZE:
         case NGX_ERROR_IGNORE_EINVAL:
         case NGX_ERROR_IGNORE_ECONNRESET:
@@ -1615,6 +1619,9 @@ ngx_connection_error(ngx_connection_t *c
             level = NGX_LOG_ERR;
         }
 
+    } else if (c->log_error == NGX_ERROR_DEBUG) {
+        level = NGX_LOG_DEBUG;
+
     } else {
         level = NGX_LOG_ALERT;
     }