Skip to content

App logs

Fetch recent logs for an app version.

Logs are scoped to an app version. Fetch the app to get activeVersion.id / active_version.id, then query logs with filters.

Resolve the active version

Retrieve the app by ID. Use activeVersion.id / active_version.id as the version when listing logs.

getAppLogs.jsget_logs.py
const app = await client.apps.retrieve("da_XYZ");
if (!app.activeVersion) {
  throw new Error("App active version not found");
}
app = client.apps.retrieve("da_XYZ")
print(app.active_version.id)

Fetch logs

Pass version (from the previous step), since, and limit. Optional: until, streams (STDOUT, STDERR, RUNTIME), textSearch / text_search, and instanceId / instance_id. Each log entry includes datetime, message, and stream.

getAppLogs.jsget_logs.py
const last30Minutes = new Date(Date.now() - 30 * 60 * 1000);

const logs = await client.apps.versions.logs.list({
  version: app.activeVersion.id,
  since: last30Minutes,
  limit: 10,
});
// Should return: { data: [...], hasMore, nextPageCursor }
console.log(logs.data);
from datetime import datetime, timedelta, timezone

since = datetime.now(timezone.utc) - timedelta(minutes=30)
logs = client.apps.versions.logs.list(
    version=app.active_version.id,
    since=since,
    limit=10,
    streams=["STDOUT", "STDERR"],  # other options: "RUNTIME"
    text_search="error",  # substring match in log messages
    instance_id="instance-1",  # filter to one runtime instance
)
# Should return: {
print(logs.data)

Source: stackmachine/sdks examples.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close