> ## Documentation Index
> Fetch the complete documentation index at: https://namespace.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Logs

> See what your agent's commands printed, why a service failed, and what the machine logged around it.

Output stays on the Devbox after a command or service ends, so you can check what your agent ran without having watched it live.

> [!TIP]
>
> With the [Devbox skill](https://namespace.so/docs/reference/devbox-cli/agent-skills.md), ask your agent in plain language, for example: *"show me the output of my last test run"*

## Command output

Each command run with `devbox exec` or the TS SDK keeps its output and exit code under an execution ID. See [Run commands](https://namespace.so/docs/devbox/exec.md#streaming-logs).

**1. Find the execution ID**

```bash CLI theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
devbox logs list my-devbox
```

```typescript TS SDK theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
const executions = await devbox.executions.list();
```

**2. Read its output**

```bash CLI theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
devbox logs my-devbox exec_nl1f65debpkamdbdnuqra114cc
```

```typescript TS SDK theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
const execution = await devbox.executions.get(
  "exec_nl1f65debpkamdbdnuqra114cc",
);

for await (const chunk of execution.logs()) {
  process.stdout.write(chunk.stdout);
  process.stderr.write(chunk.stderr);
}
```

## Service logs

Each service keeps its own logs, so you can see what it printed before it failed and restarted. See [Services](https://namespace.so/docs/devbox/services.md#logs).

```bash CLI theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
devbox service logs my-devbox web
```

```typescript TS SDK theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
for await (const chunk of devbox.services.logs("web")) {
  process.stdout.write(chunk.stdout);
  process.stderr.write(chunk.stderr);
}
```

## System logs

When the answer isn't in your own output, check what the machine logged, such as container output and kernel messages. Each line has a timestamp, its source, such as `containers` or `kmsg`, and its stream, `stdout` or `stderr`.

> [!NOTE]
>
> Every Devbox comes with [Namespace Compute](https://namespace.so/docs/architecture/compute.md)'s built-in observability. The [`nsc` CLI](https://namespace.so/docs/reference/cli/installation) and the compute client in the TS SDK read it for any running Devbox.

**1. Find the instance ID**

Look up the Devbox's instance ID while it's running. See [Find the instance ID](https://namespace.so/docs/devbox/metrics.md#instance-id).

**2. Read the logs**

The CLI and TS SDK read the logs of the running Devbox.

```bash CLI theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
nsc logs INSTANCE_ID
```

```typescript TS SDK theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { createComputeClient } from "@namespacelabs/sdk/api/compute";

const compute = createComputeClient();

for await (const block of compute.observability.streamInstanceLogs({
  instanceId,
})) {
  for (const line of block.lines) console.log(line.stream, line.content);
}
```

## Related

* [Metrics](https://namespace.so/docs/devbox/metrics.md) to see CPU, memory, and disk usage.
* [SSH](https://namespace.so/docs/devbox/ssh.md) to look around a Devbox yourself.
* Reference: [`devbox logs`](https://namespace.so/docs/reference/devbox-cli/logs), [`nsc logs`](https://namespace.so/docs/reference/cli/logs), [SDK observability](https://namespace.so/docs/reference/typescript-sdk/compute/observability.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.