log_zmq_format
The log_zmq_format directive specifies the message format for logging data via the ZeroMQ logger module in NGINX.
Description
The log_zmq_format directive is used to define the format of log messages that are sent through the ZeroMQ logger module in NGINX. This directive allows for flexible and asynchronous logging by enabling log message formatting similar to traditional log formats. The logs can be formatted as simple text or more structured formats such as JSON, where NGINX variables can be included. The directive requires two or more arguments, where the first argument specifies a name for the format and the subsequent string defines the log message pattern itself. The log messages are sent to ZeroMQ endpoints configured via other directives, enabling efficient message delivery to various subscribers for further processing.
Config Example
http {
log_zmq_server main "/tmp/main.ipc" ipc 4 1000;
log_zmq_format main '{"remote_addr":"$remote_addr","request_uri":"$request_uri","status":"$status"}';
}Make sure to include NGINX variables in the format string correctly; otherwise, the log will not capture the expected information.
Using special characters in the message format may require additional escaping to prevent issues when processed.