cloudflare / lua-resty-logger-socket

Raw-socket-based Logger Library for Nginx (based on ngx_lua)
488 stars 130 forks source link

Buffering should be disabled when using UDP #26

Open kgs opened 7 years ago

kgs commented 7 years ago

When udp is enabled then buffering does not make sense (if I understand RFC correctly: https://tools.ietf.org/html/rfc5426#section-3.1).

Multiple log messages are merged on syslog side, since UDP syslog server treats them as one line:

Jun 4 11:27:17 localhost nginx[47871]: Hello World!#012<135>Jun 04 11:27:19 localhost nginx[47871]: Hello World!

flisky commented 7 years ago

FYI, the problem could be fixed using framing in rsyslog, and usually a newline does it.

flisky commented 7 years ago

Ah, I see the LF char. Turning off EscapeControlCharactersOnReceive option may help.

FMLS commented 7 years ago

I set flush_limit to 1, then I want to send one syslog message per datagram, but it turn to error result: logs are merged and send. In nginx log, I see that: "flush lock acquired .... no need to flush:0 .... flush lock released", many lines liks that, after that, "start _do_flush......" , Please help, thx