# 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[​](#parameters "Direct link to Parameters")

See plugin [common configurations](https://docs.api7.ai/apisix/reference/plugin-common-configurations.md) 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](https://docs.api7.ai/apisix/reference/built-in-variables.md). 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](https://docs.api7.ai/apisix/reference/apisix-expressions.md) 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](https://docs.api7.ai/apisix/reference/apisix-expressions.md) 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[​](#plugin-metadata "Direct link to 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.
