> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Monitor a Headless Project

## Article: Monitor a Headless Project

## Article Link: https://dev.wix.com/docs/go-headless/wix-managed-headless/full-integration-astro/development/monitor-a-headless-project.md

## Article Content:

# Monitor a Headless Project

Wix-managed headless projects report log messages and errors to **Wix Logs**, a live log stream in your project's dashboard. Use it to trace what your code did and to debug a released project.

> **Note:** Monitoring is available with [Wix's Astro integration](https://dev.wix.com/docs/go-headless/wix-managed-headless/about-the-astro-integration.md) only. The integration registers the client that reports your messages and errors, which doesn't happen for projects built with another web framework.

<blockquote class="important">

__Important:__
`console.log()` and the other `console` methods aren't forwarded to Wix Logs. To send a message to the log stream, call `captureMessage()` or `captureException()` as described below.

</blockquote>

This article covers:

- How to report messages and errors from your code.
- How to view them in Wix Logs.

## Before you begin

+ You must have a [Wix-managed headless project](https://dev.wix.com/docs/go-headless/wix-managed-headless/about-wix-managed-headless.md) built with [Wix's Astro integration](https://dev.wix.com/docs/go-headless/wix-managed-headless/about-the-astro-integration.md).
+ Your project must have the latest version of [`@wix/essentials`](https://dev.wix.com/docs/sdk/core-modules/essentials/introduction.md) installed.
+ Monitoring isn't available in [self-managed headless projects](https://dev.wix.com/docs/go-headless/self-managed-headless/about-self-managed-headless.md). In a self-managed project, use the monitoring tools provided by your own hosting platform.

You don't need to configure anything to start reporting. Unlike monitoring for Wix apps, headless projects don't use Sentry, so there's no DSN to add and nothing to change in `wix.config.json`.

## What reaches Wix Logs

Wix Logs shows what you report with the monitoring client. You can call it from anywhere in your project: backend endpoints, page rendering, and client-side code all report to the same log stream.

Uncaught errors in your backend code are reported for you. Report everything else yourself: `console` output isn't forwarded, and uncaught errors in client-side code aren't captured.

## Report a message

Get a monitoring client, then call `captureMessage()`:

```js
import { monitoring } from "@wix/essentials";

const monitoringClient = monitoring.getMonitoringClient();

monitoringClient.captureMessage("Visitor reached checkout");
```

The message appears in Wix Logs with a severity of **INFO**. To report it at a different severity, pass a `level`:

```js
monitoringClient.captureMessage("Inventory running low", { level: "warning" });
```

## Report an error

Call `captureException()` with the error you caught:

```js
import { monitoring } from "@wix/essentials";

const monitoringClient = monitoring.getMonitoringClient();

try {
  // ... code that might throw an error
} catch (error) {
  monitoringClient.captureException(error);
}
```

By default, errors reported with `captureException()` appear with a severity of **ERROR**.

You can attach `tags` and `contexts` to either call to record extra detail:

```js
monitoringClient.captureException(error, {
  tags: { feature: "checkout" },
  contexts: { order: { id: "1234" } },
});
```

This detail is recorded alongside the message, so you can find these entries using the search box in Wix Logs.

## Report errors from client-side code

Uncaught errors in client-side code aren't captured automatically, so catch them and report them yourself:

```js
import { monitoring } from "@wix/essentials";

const monitoringClient = monitoring.getMonitoringClient();

window.addEventListener("error", (event) => {
  monitoringClient.captureException(event.error);
});
```

## View your logs

1. Go to your project's dashboard.
1. Click **Developer Tools** > **Logging Tools**.
1. In the **Wix Logs** section, click **Open**.

Each entry shows the severity level, a timestamp, the message, and a source file.

<blockquote class="important">

__Important:__
Wix Logs is a live stream and doesn't store history. Open it before you reproduce the behavior you're investigating. If the stream doesn't appear, reload the site while the Wix Logs page is open in another tab.

</blockquote>

Include enough detail in each message to identify where it came from.

## See also

- [`monitoring` submodule](https://dev.wix.com/docs/sdk/core-modules/essentials/monitoring.md)
- [Build and Deploy a Headless Project with the Wix CLI](https://dev.wix.com/docs/go-headless/wix-managed-headless/project-development/build-and-deploy-with-the-cli.md)
- [Write Unit Tests for a Wix CLI Project](https://dev.wix.com/docs/go-headless/wix-managed-headless/project-development/write-unit-tests.md)