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>.
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.
Data Stream 2 logging format
EdgeWorkers JavaScript logging returns logs in the following format, timestamp version ds2id severity traceid spanid traceflags resource attributes body.
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.jsonfile 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.