The log built-in module is available to use in your EdgeWorkers code bundles to log messages generated during the current request.

You need to enable enhanced debug headers to view the logging results from the log module.

Logging only occurs once you've requested logging information using Enable enhanced debug headers. For more information refer to the JavaScript logging section.

log()

Replaces the format string with the contents of the arguments parameter. The event handler log headers records this change. If you disable logging, the format string is not replaced and the event log headers are not changed.

import { logger } from 'log'; // Import the logger module
export function onClientRequest (request) {
  logger.log('Hello'); // Call the log method from the logger module
}
ParameterTypeDescription
formatStringThe logging header message text.
argumentsAny typeZero or more values formatted according to the format string.

This function adheres to the log behavior defined in the WhatWG Console Standard document.

debug()

Sends a debug level logging message.

logger.debug('Hello'); // Call the debug method from the logger module
ParameterTypeDescription
formatStringThe logging header message text.
argumentsAny typeZero or more values formatted according to the format string.

Replaces the format string with the contents of the arguments parameter. The event handler log headers records this change. If you disable logging, the format string is not replaced and the event log headers are not changed.

This function adheres to the log behavior defined in the WhatWG Console Standard document.

error()

Sends a error level logging message.

logger.error('Hello'); // Call the error method from the logger module
ParameterTypeDescription
formatStringThe logging header message text.
argumentsAny typeZero or more values formatted according to the format string.

Replaces the format string with the contents of the arguments parameter. The event handler log headers records this change. If you disable logging, the format string is not replaced and the event log headers are not changed.

This function adheres to the log behavior defined in the WhatWG Console Standard document.

info()

Sends a info level logging message.

logger.info('Hello'); // Call the info method from the logger module
ParameterTypeDescription
formatStringThe logging header message text.
argumentsAny typeZero or more values formatted according to the format string.

Replaces the format string with the contents of the arguments parameter. The event handler log headers records this change. If you disable logging, the format string is not replaced and the event log headers are not changed.

This function adheres to the log behavior defined in the WhatWG Console Standard document.

trace()

Sends a trace level logging message.

logger.trace('Hello'); // Call the trace method from the logger module
ParameterTypeDescription
formatStringThe logging header message text.
argumentsAny typeZero or more values formatted according to the format string.

Replaces the format string with the contents of the arguments parameter. The event handler log headers records this change. If you disable logging, the format string is not replaced and the event log headers are not changed.

This function adheres to the log behavior defined in the WhatWG Console Standard document.

warn()

Sends a warn level logging message.

logger.warn('Hello'); // Call the warn method from the logger module
ParameterTypeDescription
formatStringThe logging header message text.
argumentsAny typeZero or more values formatted according to the format string.

Replaces the format string with the contents of the arguments parameter. The event handler log headers records this change. If you disable logging, the format string is not replaced and the event log headers are not changed.

This function adheres to the log behavior defined in the WhatWG Console Standard document.