POBV - JavaScript Logging details (COPY)
You can deliver the JavaScript logs via Enhanced debug headers or a DataStream 2.
Enhanced debug header logging details
Each event handler returns a corresponding response header. A response header is only returned when logging information is available for the event. The log header name starts with X-Akamai-EdgeWorker:
- X-Akamai-EdgeWorker-onClientRequest-Log
- X-Akamai-EdgeWorker-onOriginRequest-Log
- X-Akamai-EdgeWorker-onClientResponse-Log
- X-Akamai-EdgeWorker-onOriginResponse-Log
- X-Akamai-EdgeWorker-responseProvider-Log
You can also add the X-Akamai-EdgeWorker-subworkers-Log
request header to limit which EdgeWorkers collect JavaScript logs. This can help you stay with the JavaScript Logging limits. For more information go to subWorkers JavaScript Logging details.
You can configure the JavaScript logs to appear in an LDS server log or a DataStream 2 log.
Enhanced debug header logging format
EdgeWorkers JavaScript logging returns logs in the following format <debug-level>
:<file>
:<line>
<message>
.
JavaScript Logging fields | Details | Description |
---|---|---|
<debug-level> :<file> :<line> :<message> | <debug-level> | The debug level specified in the request request header.
T- Trace |
<file> | The URL encoded file name is only included if it is different from the previous log line. | |
<line> | The line number where the log was executed. | |
<message> | The URL encoded message. Includes values for any data included in the message.
A vertical bar (|) separates multiple messages.
|
Data Stream 2 JavaScript logging details
You can generate these logs by following the steps in the Use DataStream 2 to deliver JavaScript logs tutorial.
The following is an example of the JSON data output by DataStream 2. If you select the JSON output option for your logs, timestamp
and version
are renamed to time
and format
to facilitate the naming conventions of specific endpoints.
[
{
"severity": "ERROR",
"time": "1718023875520000000",
"version": "1",
"body": "onClientRequest%20test%20%20error%20level",
"ds2id": "71321",
"format": "1",
"attributes": {
"request_id": "1a1a1a1"
},
"resource": {
"cloud.provider": "AkamaiEdgeWorkers",
"ew": "42",
"ewv": "0.9",
"ip": "<ip address of the log source>"
}
}
]
Data Stream 2 logging format
EdgeWorkers JavaScript logging returns logs in the following format, timestamp
version
ds2id
severity
traceid
spanid
traceflags
resource
attributes
body
.
Data Stream 2 logging field | Description |
---|---|
severity | The available severity levels are TRACE, DEBUG, INFO, WARN, and ERROR. |
timestamp ortime for JSON log output | Time of event handler initialization. |
version or format for JSON output | A version number specifying the format of the log line for accurate parsing. The initial value is 1. |
body | You can include any text here. The body is delivered as URL encoded data and remains encoded until it reaches the destination endpoints. Protobuf supports formatted JSON. |
ds2id | Corresponds to the streamId identified in the EdgeWorkers code bundle. This is same streamID you can use for API calls such as, get-stream . |
attributes | Additional information about the specific event occurrence. You can use this field to store information about the event handler invocation such as, if the event handler is available in the other stream formats. Including it here may increase data transfer. When written to disk as text, it provides a comma delimited name-value pair mapping to be converted into resources. |
resource | Describes information about the source of the log such as the ip , cloud.provider , ew_id , ew_version . |
Updated 5 months ago