Logs

Write logs from functions with the console, browse and filter them in the panel or over the API, and send them to stdout for your log platform.

Everything a function writes with console is captured, tagged with the function and the event, and stored by Spica.

JavaScript
export default function (req) {
  console.debug("query", JSON.stringify(req.query));
  console.info(`Greeting ${req.query.name}`);
  console.warn("Long name received", req.query.name.length);
  console.error("Something failed");
  console.log("Plain log line");
}

Levels

MethodLevelValue
console.debugDebug0
console.logLog1
console.infoInfo2
console.warnWarning3
console.errorError4

Levels are recorded when --function-logger is on, which is the default.

In the panel

Open Functions → Logs to see logs of every function on a timeline, filter them by level, function, time range and text, and expand an entry to see its details.

The function logs page with a timeline chart and a table of log entries with severity, timestamp, function, handler and content

Over the API

GET/function-logs
Query parameterDescription
functionsFunction ids. Repeat for several.
levelsLevel values, for example levels=3&levels=4 for warnings and errors.
contentText to search for.
begin, endTime range. Defaults to the current day.
channelstdout or stderr.
limit, skipPagination.
Terminal
curl -G https://api.example.com/api/function-logs \
  -H "Authorization: APIKEY <key>" \
  --data-urlencode "functions=<functionId>" \
  --data-urlencode "levels=4" \
  --data-urlencode "limit=20"
JSON
[
  {
    "_id": "6b0b1a67a5611972c29c261e",
    "function": "hello",
    "event_id": "2u2l9r31mx0qedf6",
    "channel": "stdout",
    "level": 1,
    "content": "New post created 6b0b1a67a5611972c29c261c",
    "created_at": "2026-11-28T18:16:07.799Z"
  }
]

DELETE /function-logs/<functionId> removes the logs of a function.

Retention

Logs expire after --common-log-lifespan seconds, one month by default. The same setting applies to activity and status records.

Sending logs to your platform

Choose where worker output goes with --function-worker-log-output:

ValueEffect
database (default)Stored by Spica and visible in the panel and API.
stdoutWritten to the API container's standard output, for Loki, CloudWatch, Datadog and similar tools.
database,stdoutBoth.

Add --function-invocation-logs=true to also log every invocation to stdout.

Good logging

  • Log identifiers (documentKey, user ids, order ids) so you can correlate events.
  • Use warn and error for things someone should look at, and filter on them.
  • Don't log secrets, tokens or personal data.
  • Keep debug logs cheap, or remove them once a function is stable.