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
See plugin common configurations for configuration options available to all plugins.
path
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
pathon every plugin instance. API7 Gateway 3.10.11 and APISIX 3.21.0 can inherit it from plugin metadata.log_format
Custom log entry using key-value pairs. Values can reference built-in variables. 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
Additional fields to add to the default log entry. Values can reference built-in variables, and existing default fields are not overwritten.
A plugin instance takes precedence over plugin metadata. When
log_formatis configured,log_format_extrais ignored.Introduced in API7 Enterprise 3.9.15 and 3.10.2, and in APISIX 3.18.0.
include_req_body
If true, include the request body in the default log entry. Use
max_req_body_bytesto limit the logged body size.include_req_body_expr
valid value:
at least one conditionConditions in APISIX expression format that control proactive body reading and the default
request.bodyfield. Used only wheninclude_req_bodyis true.A custom format that references
$request_bodycan 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
If true, include the response body in the default log entry. Use
max_resp_body_bytesto limit the logged body size.include_resp_body_expr
valid value:
at least one conditionConditions in APISIX expression format that control when the response body is logged. Used only when
include_resp_bodyis true.max_req_body_bytes
valid value:
greater than or equal to 1Maximum request body size, in bytes, to include in a log entry. Longer bodies are truncated.
max_resp_body_bytes
valid value:
greater than or equal to 1Maximum response body size, in bytes, to include in a log entry. Longer bodies are truncated.
match
valid value:
up to 20 expressionsOne or more APISIX expressions. A log entry is written when any expression matches the request.
Plugin Metadata
path
Default log file path for plugin instances that omit
path.API7 Gateway 3.9.25 requires
pathon every plugin instance. API7 Gateway 3.10.11 and APISIX 3.21.0 can inherit it from plugin metadata.log_format
Custom log entry used by plugin instances that do not configure
log_format. Values can reference built-in variables.Configuring
log_formaton a plugin instance takes precedence.log_format_extra
Additional fields added to the default entry for plugin instances that omit
log_format_extra. Existing default fields are not overwritten.Configuring
log_format_extraon a plugin instance, including an empty object, takes precedence. Whenlog_formatis configured,log_format_extrais ignored.