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 fieldsDetailsDescription
<debug-level>:<file>:<line>:<message><debug-level>The debug level specified in the request request header.

T- Trace
D - Debug
I - Info
W - Warn
E - Error

<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.

  • All text in the string is ASCII. Invalid characters and delimiters are percent encoded.

  • A dollar sign appends text truncated by the byte limit.

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 fieldDescription
severityThe available severity levels are TRACE, DEBUG, INFO, WARN, and ERROR.
timestamp or
time for JSON log output
Time of event handler initialization.
version or format for JSON outputA version number specifying the format of the log line for accurate parsing.
The initial value is 1.
bodyYou 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.
ds2idCorresponds to the streamId identified in the EdgeWorkers code bundle. This is same streamID you can use for API calls such as, get-stream.
attributesAdditional 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.
resourceDescribes information about the source of the log such as the ip, cloud.provider, ew_id, ew_version.