Skip to content

feat: added max/resp_body_bytes attr to logger plugins#13034

Open
janiussyafiq wants to merge 7 commits intoapache:masterfrom
janiussyafiq:feat/http-logger-max-attr
Open

feat: added max/resp_body_bytes attr to logger plugins#13034
janiussyafiq wants to merge 7 commits intoapache:masterfrom
janiussyafiq:feat/http-logger-max-attr

Conversation

@janiussyafiq
Copy link
Contributor

@janiussyafiq janiussyafiq commented Feb 26, 2026

Description

Synchronize max/resp body size attributes to other logger plugins, just like the PR here: #11133. Also added test case to http-logger similar 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:

  • http-logger
  • skywalking-logger
  • tcp-logger
  • rocketmq-logger
  • udp-logger
  • clickhouse-logger
  • syslog
  • sls-logger
  • file-logger
  • loggly
  • elasticsearch-logger
  • tencent-cloud-cls
  • loki-logger

Below logger might not be compatible hence attributes not getting added:

  • log-rotate
  • error-log-rotate
  • google-cloud-logging
  • splunk-hec-logging
  • lago

Also, haven't updated Chinese documentation.

Which issue(s) this PR fixes:

Fixes #12130

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@janiussyafiq janiussyafiq marked this pull request as ready for review February 26, 2026 08:22
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request labels Feb 26, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_bytes schema attributes (default 524288) to multiple logger plugins and update docs accordingly.
  • Add access-phase request body pre-reading for logger plugins when include_req_body is enabled (and optionally gated by include_req_body_expr).
  • Add a new t/plugin/http-logger-large-body.t test 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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

end


function _M.access(conf, ctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we try to reuse those duplicated code?

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add max request and response body size attributes to http-logger plugin

3 participants