Skip to main content

UDP Logger Configuration

The udp-logger plugin sends gateway request and response logs as JSON batches to UDP collectors with customizable formats and retry controls. Configuration covers plugin parameters and plugin metadata.

Parameters​

See plugin common configurations for configuration options available to all plugins.

  • host

    string

    required


    Hostname or IP address of the UDP collector.

  • port

    integer

    required

    valid value:

    greater than or equal to 0

    Port of the UDP collector.

  • timeout

    integer

    default: 3

    valid value:

    greater than or equal to 1

    Collector send timeout in seconds.

  • log_format

    object


    Custom log entry using key-value pairs. Values can reference built-in variables. Configuring this field replaces the default format.

    APISIX supports nested structures up to five levels and truncates deeper content. API7 Gateway supports flat structures.

    A plugin-instance value takes precedence over plugin metadata.

  • log_format_extra

    object


    Fields added to the default log entry. Existing default fields are not overwritten, and this field is ignored when log_format is configured.

    A plugin-instance value, including an empty object, takes precedence over plugin metadata.

    Introduced in API7 Enterprise 3.9.15 and 3.10.2, and in APISIX 3.18.0.

  • include_req_body

    boolean

    default: false


    If true, collect the request body for the default log entry.

  • include_req_body_expr

    array[array]

    valid value:

    at least one condition

    Conditions in APISIX expression format that control proactive request-body reading for the default log entry when include_req_body is true.

    A custom format that references $request_body can still include a body already buffered by NGINX when the conditions evaluate false. Do not use this field as a data-redaction boundary.

  • include_resp_body

    boolean

    default: false


    If true, collect the response body for the default log entry.

  • include_resp_body_expr

    array[array]

    valid value:

    at least one condition

    APISIX expressions controlling when the response body is collected. Used only when include_resp_body is true.

  • max_req_body_bytes

    integer

    default: 524288

    valid value:

    greater than or equal to 1

    Maximum request-body bytes included in a log entry. Longer bodies are truncated. Introduced in API7 Enterprise 3.10.3 and in APISIX 3.16.0. Not available in API7 Enterprise 3.9.x.

  • max_resp_body_bytes

    integer

    default: 524288

    valid value:

    greater than or equal to 1

    Maximum response-body bytes collected before decoding. Longer uncompressed bodies are truncated.

    In APISIX 3.21.0 and API7 Gateway 3.10.11, a compressed response is limited before decoding, so the decoded value written to the log can exceed this size. Keep the resulting log entry within the UDP collector and network limits.

    Introduced in API7 Enterprise 3.10.3 and in APISIX 3.16.0. Not available in API7 Enterprise 3.9.x.

  • name

    string

    default: udp logger


    Batch-processor identifier exported in batch-processing metrics.

  • batch_max_size

    integer

    default: 1000

    valid value:

    greater than or equal to 1

    Entries in one batch. A value of 1 sends each entry immediately as one JSON object; larger batches are JSON arrays.

    Batch processors are local to each gateway worker, so requests handled by different workers can be sent in separate batches.

  • inactive_timeout

    integer

    default: 5

    valid value:

    greater than or equal to 1

    Seconds without a new entry before the current batch is sent. For timely flushing, set this value lower than buffer_duration.

  • buffer_duration

    integer

    default: 60

    valid value:

    greater than or equal to 1

    Maximum age in seconds of the oldest entry before a batch is sent.

  • retry_delay

    integer

    default: 1

    valid value:

    greater than or equal to 0

    Seconds between failed send attempts.

  • max_retry_count

    integer

    default: 0

    valid value:

    greater than or equal to 0

    Failed retries allowed before a batch is dropped.

Plugin Metadata​

  • log_format

    object


    Default custom format for plugin instances that do not configure log_format.

  • log_format_extra

    object


    Default additional fields for plugin instances that do not configure log_format_extra.

  • max_pending_entries

    integer

    default: 8192

    valid value:

    greater than or equal to 1

    Maximum queued entries. New entries are discarded when the backlog reaches this limit.