# basemodo logs

Follow an App's Logs live, or print its last lines with --lines.

```sh
basemodo logs [OPTIONS]
```

Logs are what the App's processes print and what its builds print, kept 7 days. Each line of the App's Machine names its Process: the one that printed it, or the one a notice of Basemodo's is about (`basemodo` when it is about none). Without --lines, --after, --before or --search the CLI follows them until interrupted; an agent gets the latest 100 lines and a cursor, follows by asking again with --after, and pages back with --before. --search finds the lines that mention a text, in any case, in all that is kept, newest matches first. A control character in a line (an escape, a carriage return) prints as \x1b or \x0d, so a line cannot drive your terminal; --json keeps every line exact.

## Arguments

- `--app <APP>`: The App whose Logs to read. Default: the one named after the current folder.
- `--lines <N>`: Print the last N lines and stop, instead of following.
- `--after <CURSOR>`: Print the lines after this cursor (of an earlier `--json` answer, or of one of its lines) and stop.
- `--before <CURSOR>`: Print the lines before this cursor (an earlier `--json` answer's `older_cursor`, or one of its lines') and stop: paging back.
- `--search <TEXT>`: Print the newest lines that contain this text, in any letter case, from every kept line, and stop. With `--before`, the matches older than it.
- `--process <NAME>` (repeatable): Only the lines of this Process (`web`, a worker, a cron), with Basemodo's notices about it. Repeat it for several: `--process web --process mailer`.
- `--source <app|build>`: Only the App's Machine's lines (app) or only its builds' (build).

Like every command, it also takes the [global options](https://basemodo.com/docs/cli#global-options) `--json` and `--api-url`.

## Examples

Follow the Logs of the App of this folder (Ctrl-C to stop):

```sh
basemodo logs
```

Print the last 50 lines and stop:

```sh
basemodo logs --lines 50
```

Print what is new since an earlier answer:

```sh
basemodo logs --after <cursor> --json
```

Print the lines before an earlier answer's oldest (its older_cursor):

```sh
basemodo logs --before <cursor> --json
```

Follow only the worker mailer, with Basemodo's notices about it:

```sh
basemodo logs --process mailer
```

Print the last 100 lines of the builds:

```sh
basemodo logs --source build --lines 100
```

Find the latest lines that mention a timeout, then older ones:

```sh
basemodo logs --search timeout --json
basemodo logs --search timeout --before <older_cursor> --json
```

## Output

With `--json`, it prints {"lines": [{"at", "source", "deploy", "process", "message", "notice", "cursor"}], "cursor", "older_cursor", "retention_days", "processes": [{"name", "running"}]}, notice true for Basemodo's own lines (a crash, a restart, a cron run), older_cursor only when older lines are kept; while following, one JSON line per log line.

## From an agent

Basemodo's [MCP](https://basemodo.com/docs/mcp) serves it as the tool [`logs`](https://basemodo.com/docs/mcp/tools/logs). It only reads, so an agent's client may run it without asking you. Its arguments are the command's, named as JSON keys: `app` (text), `lines` (number), `after` (text), `before` (text), `search` (text), `process` (list of text), `source` (text). It answers what the command prints with `--json`.

## Explained in

- [Getting started](https://basemodo.com/docs/getting-started)
- [Deploying](https://basemodo.com/docs/deploying)
- [Callers: one of your Apps calls another](https://basemodo.com/docs/callers)
- [Workers and cron](https://basemodo.com/docs/workers-and-cron)
- [Deploying from GitHub](https://basemodo.com/docs/github)
- [How Apps run](https://basemodo.com/docs/how-apps-run)
- [Plans](https://basemodo.com/docs/plans)