# TCP Logger Configuration

The `tcp-logger` plugin sends gateway request and response logs as JSON batches to TCP 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 TCP collector.

* port

  integer

  required

  valid value:

  greater than or equal to 0

  ***

  Port of the TCP collector.

* tls

  boolean

  default: `false`

  ***

  If true, encrypt the collector connection with TLS. The plugin does not verify the collector certificate.

* tls\_options

  string

  ***

  Server name sent during the TLS handshake.

* timeout

  integer

  default: `1000`

  valid value:

  greater than or equal to 1

  ***

  Collector connection and send timeout in milliseconds.

* 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 3.9.23 and 3.10.10 support 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.

* 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

  ***

  [APISIX expressions](https://docs.api7.ai/apisix/reference/apisix-expressions.md) controlling when the request body is collected. Used only when `include_req_body` is true.

* 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. Not available in API7 Gateway 3.9.23.

* max\_resp\_body\_bytes

  integer

  default: `524288`

  valid value:

  greater than or equal to 1

  ***

  Maximum response-body bytes included in a log entry. Longer bodies are truncated. Not available in API7 Gateway 3.9.23.

* name

  string

  default: `tcp 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. Must be less 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.
