# File Logger Configuration

The `file-logger` plugin writes gateway request and response logs as newline-delimited JSON files for local collection and troubleshooting.<!-- --> <!-- -->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.

* path

  string

  ***

  Path of the file to append newline-delimited JSON log entries to. The parent directory must exist and be writable by the gateway process.

  A path configured on the plugin instance takes precedence over plugin metadata.

  API7 Gateway 3.9.25 requires `path` on every plugin instance. API7 Gateway 3.10.11 and APISIX 3.21.0 can inherit it from plugin metadata.

* 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 log format.

  Route and service identifiers are included automatically when available.

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

  A value configured on the plugin instance takes precedence over plugin metadata.

* log\_format\_extra

  object

  ***

  Additional fields to add to the default log entry. Values can reference [built-in variables](https://docs.api7.ai/apisix/reference/built-in-variables.md), and existing default fields are not overwritten.

  A plugin instance takes precedence over plugin metadata. When `log_format` is configured, `log_format_extra` is ignored.

  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, include the request body in the default log entry. Use `max_req_body_bytes` to limit the logged body size.

* 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 body reading and the default `request.body` field. Used only 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 are false. Do not use this field as a data-redaction boundary.

* include\_resp\_body

  boolean

  default: `false`

  ***

  If true, include the response body in the default log entry. Use `max_resp_body_bytes` to limit the logged body size.

* include\_resp\_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 when the response body is logged. 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 size, in bytes, to include in a log entry. Longer bodies are truncated.

* max\_resp\_body\_bytes

  integer

  default: `524288`

  valid value:

  greater than or equal to 1

  ***

  Maximum response body size, in bytes, to include in a log entry. Longer bodies are truncated.

* match

  array\[array]

  valid value:

  up to 20 expressions

  ***

  One or more [APISIX expressions](https://docs.api7.ai/apisix/reference/apisix-expressions.md). A log entry is written when any expression matches the request.

## Plugin Metadata[​](#plugin-metadata "Direct link to Plugin Metadata")

* path

  string

  ***

  Default log file path for plugin instances that omit `path`.

  API7 Gateway 3.9.25 requires `path` on every plugin instance. API7 Gateway 3.10.11 and APISIX 3.21.0 can inherit it from plugin metadata.

* log\_format

  object

  ***

  Custom log entry used by plugin instances that do not configure `log_format`. Values can reference [built-in variables](https://docs.api7.ai/apisix/reference/built-in-variables.md).

  Configuring `log_format` on a plugin instance takes precedence.

* log\_format\_extra

  object

  ***

  Additional fields added to the default entry for plugin instances that omit `log_format_extra`. Existing default fields are not overwritten.

  Configuring `log_format_extra` on a plugin instance, including an empty object, takes precedence. When `log_format` is configured, `log_format_extra` is ignored.
