feat: added max/resp_body_bytes attr to logger plugins#13034
Open
janiussyafiq wants to merge 7 commits intoapache:masterfrom
Open
feat: added max/resp_body_bytes attr to logger plugins#13034janiussyafiq wants to merge 7 commits intoapache:masterfrom
janiussyafiq wants to merge 7 commits intoapache:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR propagates request/response body size limiting (max_req_body_bytes, max_resp_body_bytes) across multiple logger plugins and adds an http-logger regression test to ensure large bodies are truncated correctly when body logging is enabled.
Changes:
- Add
max_req_body_bytes/max_resp_body_bytesschema attributes (default 524288) to multiple logger plugins and update docs accordingly. - Add
access-phase request body pre-reading for logger plugins wheninclude_req_bodyis enabled (and optionally gated byinclude_req_body_expr). - Add a new
t/plugin/http-logger-large-body.ttest covering truncation behavior and schema validation for max body byte settings.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| t/plugin/http-logger-large-body.t | New regression test ensuring request/response bodies are truncated per configured max byte limits. |
| apisix/plugins/http-logger.lua | Adds max body byte schema fields and access-phase request-body pre-read. |
| apisix/plugins/tcp-logger.lua | Adds max body byte schema fields and access-phase request-body pre-read. |
| apisix/plugins/udp-logger.lua | Adds max body byte schema fields and access-phase request-body pre-read. |
| apisix/plugins/syslog.lua | Adds max body byte schema fields and access-phase request-body pre-read. |
| apisix/plugins/tencent-cloud-cls.lua | Adds max body byte schema fields and reads request body only when sampled and enabled. |
| apisix/plugins/sls-logger.lua | Adds max body byte schema fields and access-phase request-body pre-read. |
| apisix/plugins/skywalking-logger.lua | Adds max body byte schema fields and access-phase request-body pre-read. |
| apisix/plugins/rocketmq-logger.lua | Adds max body byte schema fields and access-phase request-body pre-read. |
| apisix/plugins/loki-logger.lua | Adds max body byte schema fields and access-phase request-body pre-read. |
| apisix/plugins/loggly.lua | Adds max body byte schema fields and access-phase request-body pre-read. |
| apisix/plugins/file-logger.lua | Adds max body byte schema fields and access-phase request-body pre-read. |
| apisix/plugins/clickhouse-logger.lua | Adds max body byte schema fields and access-phase request-body pre-read. |
| apisix/plugins/elasticsearch-logger.lua | Adds max body byte schema fields and access-phase request-body pre-read (but currently has a critical access-handler override bug). |
| docs/en/latest/plugins/http-logger.md | Documents the new max body byte attributes. |
| docs/en/latest/plugins/tcp-logger.md | Documents the new max body byte attributes. |
| docs/en/latest/plugins/udp-logger.md | Documents the new max body byte attributes. |
| docs/en/latest/plugins/syslog.md | Documents the new max body byte attributes. |
| docs/en/latest/plugins/tencent-cloud-cls.md | Documents the new max body byte attributes. |
| docs/en/latest/plugins/sls-logger.md | Documents the new max body byte attributes (currently breaks table formatting). |
| docs/en/latest/plugins/skywalking-logger.md | Documents the new max body byte attributes. |
| docs/en/latest/plugins/rocketmq-logger.md | Documents the new max body byte attributes. |
| docs/en/latest/plugins/loki-logger.md | Documents the new max body byte attributes. |
| docs/en/latest/plugins/loggly.md | Documents the new max body byte attributes (currently breaks table formatting). |
| docs/en/latest/plugins/file-logger.md | Documents the new max body byte attributes (currently breaks table formatting). |
| docs/en/latest/plugins/elasticsearch-logger.md | Documents the new max body byte attributes (currently breaks table formatting). |
| docs/en/latest/plugins/clickhouse-logger.md | Documents the new max body byte attributes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
membphis
reviewed
Mar 2, 2026
| end | ||
|
|
||
|
|
||
| function _M.access(conf, ctx) |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Synchronize max/resp body size attributes to other logger plugins, just like the PR here: #11133. Also added test case to
http-loggersimilar to https://github.com/apache/apisix/blob/3ccbfd6e4678834585af3b4a7198982c5d020034/t/plugin/kafka-logger-large-body.t, to ensure robust and correct use of the attributes, preventing bugs in the future. Since the test is passing, no need to add test cases for each logger. Here is the list of all logger plugins that are updated:Below logger might not be compatible hence attributes not getting added:
Also, haven't updated Chinese documentation.
Which issue(s) this PR fixes:
Fixes #12130
Checklist