---
url: https://rustrak.dev/usage/logs/
---

# Logs

Logs are the structured lines your app writes as it runs: "order created", "carrier quote took 900 ms". Rustrak keeps them per project under **Logs**, apart from issues, so you can see what the app was doing before something broke. They are not grouped: every line is stored and shown as it came.

## Send logs

Logs are off by default in Sentry SDKs. Turn them on in `Sentry.init` and use the SDK's logger:

```javascript
import * as Sentry from '@sentry/node';

Sentry.init({
  dsn: 'YOUR_DSN',
  enableLogs: true,
});

Sentry.logger.info('Order created', { orderId: 9182, total: 54.9 });
Sentry.logger.warn('Carrier quote slow', { carrier: 'dhl', ms: 1830 });
Sentry.logger.error('Payment webhook signature mismatch');
```

Rustrak takes Sentry's `log` envelope item, so any SDK version that sends logs works. Older JavaScript SDKs put the switch under `_experiments: { enableLogs: true }`. The SDK sends logs in batches, so they show up a few seconds later; call `Sentry.flush()` before a script exits.

Each line keeps its level, message, timestamp and attributes, each attribute with its type. A line written inside an active span also carries the span's trace and span IDs.

The SDK adds a few attributes of its own to every line, among them `sentry.environment` and `sentry.release`. Rustrak reads the environment into a field of its own, so the list can be filtered by it. SDKs send `production` unless you set `environment` in `Sentry.init`. A line that arrives without one has no environment, the way Sentry leaves it.

## Levels

| Level | Severity number |
|---|---|
| `trace` | 1 |
| `debug` | 5 |
| `info` | 9 |
| `warn` | 13 |
| `error` | 17 |
| `fatal` | 21 |

A line sent without a level is stored as `info`. An unknown level is kept as sent, with no severity number.

## Find a line

**Logs** shows the newest lines first, in a table of time, level, message and environment, with a chart of the volume by level above it.

- Type in the search bar to find lines whose message contains the text, ignoring case.
- `level:error` keeps one level; `trace:<trace id>` keeps one trace.
- **Environment** keeps the lines of one environment. It lists every environment the project has seen in issues, sessions and logs.
- The window button (`14d` by default) sets how far back to look.

Every filter is in the address, so a reload or a shared link shows the same lines.

Save a search you repeat as a [view](https://rustrak.dev/usage/saved-views/).

Click a line to open it in place, under its row. It shows the whole message, then its time, environment, trace and span, then its attributes grouped by namespace (`sentry`, `service` and so on). Hover a value to copy it, or click **Copy JSON** for the whole line. `j` and `k` move to the next and previous line, and `Esc` closes it.

The filter button beside the environment or the trace narrows the list to it. The trace filter keeps the others, so remove `level:` to see every line of the request.

## API

Read logs with an [API token](https://rustrak.dev/usage/tokens/):

```bash
curl -H "Authorization: Bearer $RUSTRAK_TOKEN" \
  "$RUSTRAK_URL/api/projects/3/logs?level=error&query=renewal&period=7d&per_page=50"
```

| Parameter | What it does |
|---|---|
| `level` | One level |
| `trace_id` | One trace |
| `environment` | One environment, as the SDK sent it |
| `query` | Message contains this text, ignoring case |
| `period` | Window such as `24h`, `7d`, `14d`. All time when absent |
| `page`, `per_page` | Pagination. `per_page` is 20 by default, at most 100 |

`GET /api/projects/{id}/logs/{log_id}` returns one line and `GET /api/projects/{id}/logs/volume` the counts behind the chart. The [MCP server](https://rustrak.dev/sdks/mcp/) reads logs too.

Logs count toward storage and are removed by retention like the rest of the data. See [Storage](https://rustrak.dev/usage/storage/).
