Mercurial > hg > nginx
comparison src/http/modules/ngx_http_log_module.c @ 9224:c7c8354f99fa
Syslog: fixed duplicate errors with access logging to syslog.
The ngx_syslog_send() function logs errors itself, so there is no need
to additionally log errors in the caller, notably access log modules in
http and stream.
To ensure that incomplete and blocked writes are also logged, appropriate
logging added to ngx_syslog_send().
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 01 Mar 2024 05:42:09 +0300 |
parents | 265c29b0b8b8 |
children |
comparison
equal
deleted
inserted
replaced
9223:697f452bc033 | 9224:c7c8354f99fa |
---|---|
252 | 252 |
253 static ngx_int_t | 253 static ngx_int_t |
254 ngx_http_log_handler(ngx_http_request_t *r) | 254 ngx_http_log_handler(ngx_http_request_t *r) |
255 { | 255 { |
256 u_char *line, *p; | 256 u_char *line, *p; |
257 size_t len, size; | 257 size_t len; |
258 ssize_t n; | |
259 ngx_str_t val; | 258 ngx_str_t val; |
260 ngx_uint_t i, l; | 259 ngx_uint_t i, l; |
261 ngx_http_log_t *log; | 260 ngx_http_log_t *log; |
262 ngx_http_log_op_t *op; | 261 ngx_http_log_op_t *op; |
263 ngx_http_log_buf_t *buffer; | 262 ngx_http_log_buf_t *buffer; |
374 p = op[i].run(r, p, &op[i]); | 373 p = op[i].run(r, p, &op[i]); |
375 } | 374 } |
376 | 375 |
377 if (log[l].syslog_peer) { | 376 if (log[l].syslog_peer) { |
378 | 377 |
379 size = p - line; | 378 (void) ngx_syslog_send(log[l].syslog_peer, line, p - line); |
380 | |
381 n = ngx_syslog_send(log[l].syslog_peer, line, size); | |
382 | |
383 if (n < 0) { | |
384 ngx_log_error(NGX_LOG_WARN, r->connection->log, 0, | |
385 "send() to syslog failed"); | |
386 | |
387 } else if ((size_t) n != size) { | |
388 ngx_log_error(NGX_LOG_WARN, r->connection->log, 0, | |
389 "send() to syslog has written only %z of %uz", | |
390 n, size); | |
391 } | |
392 | 379 |
393 continue; | 380 continue; |
394 } | 381 } |
395 | 382 |
396 ngx_linefeed(p); | 383 ngx_linefeed(p); |