Skip to Content
ObservabilityApp logs

App logs

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.js
1
const app = await client.apps.retrieve("da_XYZ");
2
if (!app.activeVersion) {
3
  throw new Error("App active version not found");
4
}

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.js
1
const last30Minutes = new Date(Date.now() - 30 * 60 * 1000);
2
 
3
const logs = await client.apps.versions.logs.list({
4
  version: app.activeVersion.id,
5
  since: last30Minutes,
6
  limit: 10,
7
});
8
// Should return: { data: [...], hasMore, nextPageCursor }// { ... }
9
console.log(logs.data);

Source: stackmachine/sdks  examples.