Score:2

Can nginx log to an arbitrary UDP socket?

cm flag
Tom

Is it possible to make nginx log its access logs to an arbitrary UDP socket, logging only the output of the log format?

The syslog facility comes close but seems to insist on adding a header with the timestamp, hostname and programname. I'm trying to log to a service that accepts a JSON-formatted payload. I've written an nginx log_format that produces a JSON document, but can't figure out how to get it to produce only that.

djdomi avatar
za flag
i think you have to convert the output by using http://nginx.org/en/docs/syslog.html a other option isnt known to me. You may also modify the output by using a custom log format
cm flag
Tom
@djdomi I'd found the log_format directive but when you log that to syslog, it still prepends an RFC3164 header, even if the message contains a valid RFC5424 header. On digging further, the reason for this seems to be that nginx just uses the system libc's `syslog(3)` call and glibc's still uses RFC3164. Use nginx on *bsd and it generates RFC5424 headers.
djdomi avatar
za flag
you may want to add or solve your question on your own i think noone else will do that ;)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.