log

Outputs a message to the Logs section of the Developer Console. Useful for debugging, tracking script execution, and monitoring variable values.

{% log "Hello world!" %}
{% log order.name %}
{% log "Order total: " | append: order.total_price %}

Syntax

{% log value %}
{% log value | filter %}
{% log "string" | append: variable %}

Parameters

Parameter
Required
Description

value

Yes

Any value to log - string, number, object, array, or variable

Output Formatting

The log tag automatically formats output based on the value type:

Value Type
Output

String

Displayed as-is

Number

Displayed as-is

Object

JSON-formatted with indentation

Array

JSON-formatted with indentation

null

Displayed as "null"

undefined

Displayed as "undefined"

Examples

Log a simple message:

Log a variable:

Log with appended values:

Log calculation results:

Debug conditional logic:

Log loop progress:

Log object properties:

Log entire objects for debugging:

Log array contents:

Track script execution flow:

Log with JSON filter for complex objects:

Conditional logging:

Notes

  • Logs appear in the Logs section of the Developer Console

  • Objects and arrays are automatically JSON-formatted with 2-space indentation

  • Maximum log length is 20,000 characters - longer logs are truncated

  • Supports Liquid filters for formatting (e.g., | append:, | upcase, | date:)

  • No credit cost for logging

  • Use logs liberally during development, consider reducing in production for cleaner output

Last updated