The log component

A component that writes messages to the server logs. When a page runs, it prints your message to the terminal/console (standard error). Use it to track what happens and troubleshoot issues.

Where do the messages appear?

  • Running from a terminal (Linux, macOS, or Windows PowerShell/Command Prompt): they show up in the window.
  • Docker: run docker logs <container_name>.
  • Linux service (systemd): run journalctl -u sqlpage.
  • Output is written to standard error (stderr).

Introduced in SQLPage v0.37.1.

Top-level parameters

name required type description
message REQUIRED

TEXT

The text to write to the server logs. It is printed when the page runs.
level

TEXT

How important the message is. One of 'trace', 'debug', 'info' (default), 'warn', 'error'. Not case-sensitive. Controls the level shown in the logs.
No data

Examples

Record a simple message

This writes "Hello, World!" to the server logs.

SELECT 'log' as component, 'Hello, World!' as message;

Example output:

[2025-09-13T22:30:14.722Z INFO  sqlpage::log from "x.sql" statement 1] Hello, World!

Set the importance (level)

Choose how important the message is.

SELECT 'log' as component, 'error' as level, 'This is an error message' as message;

Example output:

[2025-09-13T22:30:14.722Z ERROR sqlpage::log from "x.sql" statement 2] This is an error message

Log dynamic information

Include variables like a username.

set username = 'user'

select 'log' as component,
        '403 - failed for ' || coalesce($username, 'None') as message,
        'error' as level;

See also: other components