Skip to main content

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​

See plugin common configurations 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. 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 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 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​

  • 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.