pipelog_format

Defines a log format for sending HTTP access log entries to an external program via a pipe.

Syntaxpipelog_format name [escape=default|json|none] string ...;
Defaultnone
Contexthttp, server, location
Arguments2+

Description

The pipelog_format directive in the NGINX pipelog module allows administrators to define custom log formats for HTTP access logs that are sent to external processes. Similar to the log_format directive found in the standard HTTP logging system, it supports a flexible syntax where users can specify various variables to include in their log entries, such as client IP address, request time, response status, and more. Additionally, the directive allows for an 'escape' parameter to modify how strings are logged, with options for default escaping, JSON formatting, or disabling escaping entirely.

In use, pipelog_format can be declared within the http, server, or location contexts and it requires at least two arguments: the name of the format and the format string itself. The format string can include various NGINX variables, which will be dynamically replaced with relevant data during each request. This format definition can then be linked to the pipelog directive to specify the external command that processes the log entries.

Overall, pipelog_format provides a powerful way to customize the logging behavior of NGINX, enhancing its ability to communicate with external logging systems or processors. By leveraging this directive, users can tailor their logging strategy to meet specific operational or analytical needs, allowing for greater flexibility in their infrastructure setup.

Config Example

pipelog_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent';

Ensure that the format name does not conflict with existing log format names.

The escape option should be set appropriately based on the output requirements; incorrect settings may lead to malformed logs.

If using special characters within strings, be mindful of escaping rules in NGINX configuration.

← Back to all directives