JavaScript Logging details
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",
"nl": "1",
},
"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. |
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 . |
traceid | Currently unused field. Reserved for future use with Open Telemetry standard. |
spanid | Currently unused field. Reserved for future use with Open Telemetry standard. |
traceflags | Currently unused field. Reserved for future use with Open Telemetry standard. |
resource | Describes information about the source of the log such as the ip , cloud.provider , ew_id , ew_version . |
attributes | Additional information about the specific event occurrence. You can use this field to correlate other log entries saved for the same request. It also includes an nl flag if the number of logging messages sent within one second is close to the limit . For example, nl: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. |
DataStream 2 and the EdgeWorkers access model
For an EdgeWorker to access a DataStream 2 object it has to be part of or share access to common group.
This means that the EdgeWorker needs to be:
- A member of the same group as the Data Stream 2 object.
- Or in a group that belongs to the one that the Data Stream 2 object is assigned to.
You cannot use a DataStream 2 stream for log delivery if the EdgeWorker does not meet the Access control requirements. For more information go to the Identity and Access Management guide.
DataStream 2 log delivery
You can deliver the log entries in up to two separate streams.
-
In the
bundle.json
file in the EdgeWorkers code bundle. -
Via the EdgeWorkers CLI where you can add additional independent streams to deliver logs. If you configure the streams independently from each other, you can apply different log level filters.
Updated 14 days ago