Controls request and response body logging in HTTP handlers. Map from a handler lookup key to logging settings. By default, the key is the low cardinality request path. Query parameters are not included, and path parameters are included in their raw form as written in the handler config. Handwritten handlers may explicitly select JSON masking settings by a custom handler name instead. Slash-prefixed keys are validated against registered static handler paths; other custom names are not validated. Examples of keys: /v1/orders/{order_id} and dynamic-proxy-orders. The value contains optional size limits and independent JSON masking policies for requests and responses. For custom names, a size limit is applied only when the corresponding JSON masking policy is configured.
# yaml
default: {}
description: |
Controls request and response body logging in HTTP handlers. Map from a handler lookup key to logging settings.
By default, the key is the low cardinality request path. Query parameters are not included, and path parameters
are included in their raw form as written in the handler config. Handwritten handlers may explicitly select
JSON masking settings by a custom handler name instead. Slash-prefixed keys are validated against registered
static handler paths; other custom names are not validated. Examples of keys: `/v1/orders/{order_id}` and
`dynamic-proxy-orders`.
The value contains optional size limits and independent JSON masking policies for requests and responses.
For custom names, a size limit is applied only when the corresponding JSON masking policy is configured.
schema:
type: object
description: |
Controls request and response body logging in HTTP handlers. Map from a handler lookup key to logging settings.
By default, the key is the low cardinality request path. Query parameters are not included, and path parameters
are included in their raw form as written in the handler config. Handwritten handlers may explicitly select
JSON masking settings by a custom handler name instead. Slash-prefixed keys are validated against registered
static handler paths; other custom names are not validated. Examples of keys: `/v1/orders/{order_id}` and
`dynamic-proxy-orders`.
The value contains optional size limits and independent JSON masking policies for requests and responses.
For custom names, a size limit is applied only when the corresponding JSON masking policy is configured.
example:
/v1/orders/{order_id}:
request_body_size_log_limit: 128
response_body_size_log_limit: 256
/v1/profile:
request_body_size_log_limit: 0
response_body_size_log_limit: 512
json_response_body_masking:
list_mode: whitelist
paths:
- [status]
- [user, id]
dynamic-proxy-orders:
request_body_size_log_limit: 512
json_request_body_masking:
paths:
- [user, phone]
additionalProperties:
type: object
additionalProperties: false
properties:
request_body_size_log_limit:
type: integer
minimum: 0
description: |
Maximum request body size in bytes.
response_body_size_log_limit:
type: integer
minimum: 0
description: |-
Maximum response body size in bytes.
json_request_body_masking:
$ref: '#/definitions/BodyMasking'
json_response_body_masking:
$ref: '#/definitions/BodyMasking'
definitions:
BodyMasking:
type: object
additionalProperties: false
required:
- paths
description: |
Generated handlers skip masking for operations recognized as binary-only by their
Swagger/OpenAPI schema. Otherwise, setting a rule explicitly opts the body into JSON
processing, including typed responses and framework errors without a schema-defined object.
Handwritten handlers must opt in explicitly.
Runs after View::GetRequestBodyForLogging() for requests, or
View::GetResponseForLogging()/View::GetNonSchemaResponseForLogging() for responses.
Rules process the hook's output, so even a dynamic whitelist cannot restore
data that the hook has masked or removed.
Masking stops at the effective body log limit. The UTF-8-safe prefix may be incomplete JSON.
Its ...(truncated, total N bytes) suffix also fits within the limit; N is the byte size
after custom hooks, before JSON masking. Very small limits may truncate the suffix itself.
Non-JSON hook output produces an error marker.
properties:
list_mode:
type: string
enum:
- blacklist
- whitelist
default: blacklist
description: |
Blacklist masks selected subtrees; whitelist preserves only selected subtrees.
An empty blacklist preserves everything; an empty whitelist masks the root.
paths:
type: array
description: |
Each path is an array of object member names, called segments.
For example, ["users", "phone"] has segments "users" and "phone".
An empty path [] selects the root.
Array elements need no extra segment: ["users", "phone"] selects "phone"
in every object of {"users": [{"phone": "123"}, {"phone": "456"}]}.
The segment '*' matches any object member name. For example,
["users", "*", "phone"] selects users.alice.phone and users.bob.phone.
A named segment overrides '*' at the same level. With paths
["users", "alice", "id"] and ["users", "*", "phone"], users.alice.id and
users.bob.phone are selected, but users.alice.phone is not: after choosing
"alice", matching never returns to the '*' branch, even if "id" is absent.
Masked scalars become "...", objects "{...}", and arrays "[...]".
items:
type: array
items:
type: string