Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt

Use this file to discover all available pages before exploring further.

Container logs are stdout and stderr from a sandbox’s main process. Stream them with stream_logs(), which captures output from the command passed to Sandbox.run(). Output from exec() commands is not included. Use Process.stdout or Process.stderr for that. Returns a StreamReader that yields log lines. Iterate synchronously or asynchronously.
When you call Sandbox.run() without a command, the sandbox’s default command does not write to stdout or stderr, so stream_logs() returns no output. Pass a command that writes to stdout or stderr.

Retrieve recent logs

for line in sandbox.stream_logs(tail_lines=100):
    print(line, end="")

Follow mode

Stream logs continuously, like tail -f. The iterator blocks until new data arrives.
for line in sandbox.stream_logs(follow=True):
    print(line, end="")
Press Ctrl-C to stop when iterating in follow mode.

Filter by time

Only retrieve logs after a specific timestamp.
from datetime import datetime, timezone

since = datetime(2026, 2, 20, 14, 0, 0, tzinfo=timezone.utc)
for line in sandbox.stream_logs(since_time=since):
    print(line, end="")

Timestamps

Prefix each line with an ISO 8601 timestamp from the server.
for line in sandbox.stream_logs(tail_lines=10, timestamps=True):
    print(line, end="")
# Output: 2026-02-20T14:30:00Z some log line

Async iteration

async for line in sandbox.stream_logs(follow=True):
    print(line, end="")

Retrieving logs from stopped sandboxes

You can retrieve historical logs from sandboxes that have already completed, failed, or been terminated:
sb = Sandbox.from_id("sbx-abc123").result()
for line in sb.stream_logs(tail_lines=50):
    print(line, end="")
Only follow=False (the default) is supported for stopped sandboxes.

See also

Last modified on May 20, 2026