JavaScript logging

Add the built-in log module to your EdgeWorker functions to aid in the development process.

The log module captures log messages generated during the current request. In addition to logging static strings, EdgeWorkers logs can also include dynamic data. For more information see Add dynamic data to log messages.
Important: When adding JavaScript logging to your EdgeWorkers make sure you take the necessary precautions to validate that sensitive data is not included in the log output.
The following restrictions apply to logging headers:
  • Logging headers are not cached.
  • The logging header includes all messages logged for the specified event handler.
  • The total log size per event handler is limited to 1024 bytes. If you exceed the limit the results are truncated to 1024 bytes.
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> Currently the level is always "D" for debug.
<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.
Multiple messages are separated by a vertical bar (|).
  • All text in the string is ASCII. Invalid characters (and delimiters) are percent encoded.
  • If text is truncated by the byte limit, a dollar sign is appended to the string.