Configures custom fields in the user_defined_log_fields element of bucket real-time logs to capture specific request headers and query parameters for analysis.
Usage notes
-
To call the PutUserDefinedLogFieldsConfig operation, you must have the
oss:PutUserDefinedLogFieldsConfigpermission. For more information, see Grant a custom policy. -
Logged data is stored as Base64-encoded JSON in the
user_defined_log_fieldsfield. The JSON contains three keys: "truncated" (whether data was truncated), "headers" (request headers), and "querys" (query parameters). -
A logging configuration supports a maximum of six custom request headers and query parameters in total.
-
The combined key and value length of all custom request header and query parameter fields in a logging configuration cannot exceed 1,024 bytes. Characters beyond this limit are truncated.
-
Request header keys allow hyphens (-) but not underscores (_). Query parameter keys allow underscores (_).
-
Request header keys must contain only ASCII printable characters (33–126), excluding underscores (_) and colons (:).
Request syntax
PUT /?userDefinedLogFieldsConfig HTTP/1.1
Date: GMT Date
Content-Length: ContentLength
Content-Type: application/xml
Host: BucketName.oss.aliyuncs.com
Authorization: SignatureValue
<?xml version="1.0" encoding="UTF-8"?>
<UserDefinedLogFieldsConfiguration>
<HeaderSet>
<header>header1</header>
<header>header2</header>
<header>header3</header>
</HeaderSet>
<ParamSet>
<parameter>param1</parameter>
<parameter>param2</parameter>
</ParamSet>
</UserDefinedLogFieldsConfiguration>
Request headers
A PutUserDefinedLogFieldsConfig request uses only common request headers. For more information, see Common request headers.
Request elements
|
Element |
Type |
Required |
Example |
Description |
|
UserDefinedLogFieldsConfiguration |
Container |
Yes |
N/A |
The container for the user-defined logging configuration. Child elements: HeaderSet and ParamSet Parent elements: none |
|
HeaderSet |
Container |
No |
N/A |
The container for custom request headers. Child elements: header Parent elements: UserDefinedLogFieldsConfiguration |
|
header |
String |
No |
header1 |
The custom request header. Child elements: none Parent elements: HeaderSet |
|
ParamSet |
Container |
No |
N/A |
The container for custom query parameters. Child elements: parameter Parent elements: UserDefinedLogFieldsConfiguration |
|
parameter |
String |
No |
param1 |
The custom query parameter. Child elements: none Parent elements: ParamSet |
Response headers
The response to a PutUserDefinedLogFieldsConfig request uses only common response headers. For more information, see Common response headers.
Examples
Sample request
PUT /?userDefinedLogFieldsConfig HTTP/1.1
Date: GMT Date
Content-Length: ContentLength
Content-Type: application/xml
Host: BucketName.oss.aliyuncs.com
Authorization: SignatureValue
<?xml version="1.0" encoding="UTF-8"?>
<UserDefinedLogFieldsConfiguration>
<HeaderSet>
<header>header1</header>
<header>header2</header>
<header>header3</header>
</HeaderSet>
<ParamSet>
<parameter>param1</parameter>
<parameter>param2</parameter>
</ParamSet>
</UserDefinedLogFieldsConfiguration>
Sample response
HTTP/1.1 200 OK
x-oss-request-id: 534B371674125A4D8906008B
Date: Date
Content-Length: 0
Connection: keep-alive
Server: AliyunOSS
OSS SDKs
You can use OSS SDKs for the following programming languages to call the PutUserDefinedLogFieldsConfig operation: