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

# Read browser and backend logs in one place during development

> Find a browser error, its stack and the backend request it failed on with one grep over .forge/logs/dev, then query the same errors with forge obs locally.

While `reliant forge env up dev` runs, the browser's console sits in a file next to your API's log. A scaffolded frontend forwards every `console` call, uncaught error and unhandled promise rejection to its dev server, and `env up` writes each service's output to `.forge/logs/dev/`. So "what did the browser do" becomes a `grep`, and a failed call's trace id leads straight to the backend lines for the same request. Your coding agent can read the same files, with no browser and no screenshot.

[Where the telemetry goes](https://docs.reliantlabs.io/hosting/observability/where-it-goes.md#the-log-directory) describes the directory and the forwarder in detail.

## Before you begin

* A Forge project with a scaffolded web frontend, running locally with `reliant forge env up dev`: [Build a Go and React app](https://docs.reliantlabs.io/guides/forge/build-go-react-app-connect-rpc.md).
* Forge v1.6.1 or later in the project (`reliant forge --version`).

The examples use that guide's `shop` app with a bug added on purpose: clicking a product row reads a field the product does not have.

**1. Find the log files**

`env up` names each service's log file in its summary:

```text Output (trimmed) theme={null}
│ Host services
│  ● api                 http://localhost:8087  up
│       ↳ .forge/logs/dev/api.log
│  ● alerts              http://localhost:9096  up
│       ↳ .forge/logs/dev/alerts.log
│ Frontends
│  ● web                 http://localhost:3000  up
│       ↳ .forge/logs/dev/frontend_web.log
```

Backend files hold JSON lines. `frontend_<name>.log` holds the dev server's output, with each browser line prefixed `[browser:<level>]`. Each `env up` starts the files afresh.

**2. Grep the browser's errors**

Reproduce the problem in the browser, then search every frontend's file at once:

```bash terminal theme={null}
grep '\[browser:error\]' .forge/logs/dev/*.log
```

```text Output theme={null}
.forge/logs/dev/frontend_web.log:[browser:error] TypeError: Cannot read properties of undefined (reading 'trim')
.forge/logs/dev/frontend_web.log:[browser:error] rpc failed procedure=/services.catalog.v1.CatalogService/GetProduct code=not_found reason=not_found message="product not found" trace_id=acdeca418458e2818488fd5fc0cb0bc4
```

The first line is an uncaught `TypeError`. It makes no `console` call anywhere in your code, so searching the source for it finds nothing. The stack follows it in the file; with Next.js the dev server also prints the line that threw:

```bash terminal theme={null}
grep -A6 'Uncaught TypeError' .forge/logs/dev/frontend_web.log
```

```text Output theme={null}
[browser] Uncaught TypeError: Cannot read properties of undefined (reading 'trim')
    at onRowClick (src/app/products/page.tsx:189:109)
    at tr (<anonymous>)
    at ProductsPage (src/app/products/page.tsx:240:7)
  187 |       columns={columns}
  188 |       rowKey={(item) => String(item.id)}
> 189 |       onRowClick={(item) => router.push(entityViewHref("products", (item as unknown as { sku: string }).sku.trim()))}
```

**3. Follow a failed call into the backend**

The second line is a failed RPC, and it carries the trace id the browser sent with the request. The backend logged the same id:

```bash terminal theme={null}
grep acdeca418458e2818488fd5fc0cb0bc4 .forge/logs/dev/*.log
```

```text Output (trimmed) theme={null}
.forge/logs/dev/api.log:{"level":"INFO","msg":"audit.event","procedure":"/services.catalog.v1.CatalogService/GetProduct","trace_id":"acdeca418458e2818488fd5fc0cb0bc4","user_id":"400464972050268161","status":"error","code":"not_found",…}
.forge/logs/dev/api.log:{"level":"INFO","msg":"rpc failed","procedure":"/services.catalog.v1.CatalogService/GetProduct","error":"not_found: product not found","error_class":"user","code":"not_found","trace_id":"acdeca418458e2818488fd5fc0cb0bc4",…}
.forge/logs/dev/frontend_web.log:[browser:error] rpc failed procedure=/services.catalog.v1.CatalogService/GetProduct code=not_found …
```

The browser reports any failed call as an error. The backend logs a `not_found` at `INFO` with `error_class=user`, because the caller asked for something that does not exist; a server fault is logged at `ERROR`.

**4. Query the same errors in the local store**

The local stack also keeps backend logs and browser errors in a queryable store, and keeps them across restarts while the files start afresh. `obs logs` reads backend logs, by trace or by query:

```bash terminal theme={null}
reliant forge obs logs dev --trace acdeca418458e2818488fd5fc0cb0bc4
```

```text Output theme={null}
TIME          SEVERITY  SERVICE  BODY
16:23:34.737  info      api      rpc failed  error="not_found: product not found" code=not_found error_class=user
16:23:34.737  info      api      audit.event  error="not_found: product not found" code=not_found
```

Browser errors are stored as error spans of the frontend's service (`<project>-<frontend>`):

```bash terminal theme={null}
reliant forge obs traces dev --service shop-web --errors --since 15m
reliant forge obs trace 19e80af4c6d53281f22204b9babd79c6 dev
```

```text Output theme={null}
TRACE                             START     DURATION  SERVICE   ROOT     SPANS    ERRORS
19e80af4c6d53281f22204b9babd79c6  16:23:30  0.0ms     shop-web  onerror  1 spans  1 err

trace 19e80af4c6d53281f22204b9babd79c6  0.0ms  1 spans
* shop-web onerror  0.0ms  ERROR TypeError: Cannot read properties of undefined (reading 'trim')
```

For `dev` these verbs read the local store without any flag. `--backend local` forces it, which is only useful when an env's declaration routes elsewhere.

**5. Fix it and confirm the errors stop**

After the fix, the dev server reloads the page. Click a row again and search once more:

```bash terminal theme={null}
grep -c '\[browser:error\] TypeError' .forge/logs/dev/frontend_web.log
```

```text Output theme={null}
0
```

The row now opens `/products/view`. To watch while you click, run `tail -f .forge/logs/dev/frontend_web.log`, or `reliant forge obs logs dev --follow --severity error` for the backend. Browser lines arrive in batches every 250 ms, and errors are sent at once.

## What this does not do

* **The browser file is development only.** The receiving endpoint exists only on the dev server, so a deployed frontend writes nothing there. Deployed browser errors become issues with source-mapped stacks: [Debug frontend errors with session timelines](https://docs.reliantlabs.io/guides/observability/debug-frontend-errors-session-timelines.md).
* **Browser console lines are not in `obs logs`.** Only the file has them. The store holds browser errors, page loads and failed requests as spans.
* **It does not record sessions.** Session replay is opt-in per environment, and masked: [Session timelines](https://docs.reliantlabs.io/hosting/observability/session-timelines.md).

## Troubleshooting

> [accordion] No \[browser: lines in frontend\_web.log
>
> The forwarder is ordinary scaffolded code: one `installDevLogging()` call in `src/main.tsx` (Vite) or `src/app/providers.tsx` (Next.js), and one dev-server receiver. If you adopted an existing app or removed either, add them back. Also check that the page was opened through the dev server `env up` started, not a production build.

> [accordion] \[browser:warn] \[forge-devlog] this dev server's /\_\_forge/log endpoint predates batched posts; update it
>
> The page's runtime batches lines but the dev server's receiver is older. Update the receiver from a current scaffold, or the lines arrive empty.

## Next steps

> [card] [Find your slowest endpoints](https://docs.reliantlabs.io/guides/observability/find-slowest-rpcs.md)
>
> Rank every RPC by p95, locally or in production.

> [card] [Debug production with an AI agent](https://docs.reliantlabs.io/guides/observability/debug-production-with-ai-agent.md)
>
> Give an agent the same evidence for a deployed app.

> [card] [Where the telemetry goes](https://docs.reliantlabs.io/hosting/observability/where-it-goes.md)
>
> The log directory, the local store and hosted telemetry.

> [card] [Querying with forge obs](https://docs.reliantlabs.io/hosting/observability/forge-obs.md)
>
> Every obs verb and its flags.


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