---
title: "Debug logging in JSS apps"
slug: "debug-logging-in-jss-apps"
abstract: "Use JSS debug logging to enhance your developer experience with production debugging for some or all of your application."
---
# Debug logging in JSS apps

Sitecore JSS NPM packages and sample applications use the [debug module](https://www.npmjs.com/package/debug) for displaying debugging information.

This module exposes the `debug()` function, an augmented version of `console.log()`. Unlike `console.log()`, you don't have to comment or remove `debug()` calls in production code, which means you can easily configure debug logs in production using environment variables, as needed.

All JSS logs are organized under the root namespace `sitecore-jss`. Logging is turned off by default, but it can be conditionally enabled using the `DEBUG` environment variable. There are also several [related environment variables](https://doc.sitecore.com/sai/en/developers/jss/22/jss-sai/debug-logging-in-jss-apps.html#UUID-7523d529-3888-0e05-ce21-8c05f6c4029a_section-idm4593678009529632613364432334 "Advanced options") that you can use to further configure the content and appearance of debug logs.

When logging is enabled and you run your application, for example with `jss start:production` or `npm run start:production`, all triggered instances of `debug()` relevant to the namespaces you choose to include will be displayed in your console.

> [!note]
> The debug logs only include server-side code, so there is no reason to [enabling debug logging in the browser](https://www.npmjs.com/package/debug#browser-support).

To output all available debug logs, set the `DEBUG` environment variable to `sitecore-jss:*`. The asterisk behaves as a wildcard.

```text
DEBUG=sitecore-jss:*

```

You can use [namespaces](https://doc.sitecore.com/sai/en/developers/jss/22/jss-sai/debug-logging-in-jss-apps.html#UUID-7523d529-3888-0e05-ce21-8c05f6c4029a_section-idm4588692370507232613361843069 "Namespaces") to selectively show a specific category of log messages, for example, layout service logs.

```text
DEBUG=sitecore-jss:layout

```

To include more than one specific log namespace, you can write the namespaces in a comma-separated list. The following example will cause debug logs to only include layout and dictionary service logs:

```text
DEBUG=sitecore-jss:layout,sitecore-jss:dictionary

```

To include everything except for specific logs, you can follow the wildcard namespace with a comma-separated list of namespaces that you want to exclude. In the following example, the logs will return everything except for layout service logs, which are excluded due to the `-` prefix:

```text
DEBUG=sitecore-jss:*,-sitecore-jss:layout

```

<details>
<summary><h2>Namespaces</h2></summary>

The following table lists all the available namespaces, along with the applicable JSS npm packages and sample applications.

| Namespace | Package(s) and sample app(s) | Description |
| --- | --- | --- |
| `sitecore-jss:http` | `sitecore-jss`, `nextjs` | HTTP request and response logging for default fetch wrappers (`GraphQLRequestClient` , `NativeDataFetcher(JSS version >= 22.4)`, and `AxiosDataFetcher(JSS version <= 22.3)`). |
| `sitecore-jss:dictionary` | `sitecore-jss`, `nextjs`, `node-headless-ssr-experience-edge` | Trace logging for dictionary service implementations (`GraphQLDictionaryService` and `RestDictionaryService`). |
| `sitecore-jss:layout` | `sitecore-jss`, `nextjs`, `node-headless-ssr-experience-edge` | Trace logging for layout service implementations (`GraphQLLayoutService` and `RestLayoutService`). |
| `sitecore-jss:editing` | `sitecore-jss-nextjs`, `nextjs` | Trace logging for Next.js middleware for SitecoreAI editor integration. |
| `sitecore-jss:personalize` | `sitecore-jss-nextjs`, `nextjs`, `nextjs-personalize` | Trace logging for Next.js Personalize middleware (`PersonalizeMiddleware`). |
| `sitecore-jss:sitemap` | `sitecore-jss-nextjs`, `nextjs`, `nextjs-sxa` | Trace logging for Next.js GraphQL sitemap service (`GraphQLSitemapService`) and Headless SXA sitemap.xml service (`GraphQLSitemapXmlService`). |
| `sitecore-jss:robots` | `sitecore-jss-nextjs`, `nextjs`, `nextjs-sxa` | Trace logging for Next.js Headless SXA robots.txt service (`GraphQLRobotsService`). |
| `sitecore-jss:redirects` | `sitecore-jss-nextjs`, `nextjs`, `nextjs-sxa` | Trace logging for Next.js Headless SXA redirects middleware (`RedirectsMiddleware`). |
| `sitecore-jss:errorpages` | `sitecore-jss-nextjs`, `nextjs`, `nextjs-sxa` | Trace logging for Next.js Headless SXA error pages service (`GraphQLErrorPagesService`). |
| `sitecore-jss:multisite` | `sitecore-jss`, `sitecore-jss-nextjs`, `nextjs`, `nextjs-multisite` | Trace logging for GraphQL site info service (`GraphQLSiteInfoService`) and Next.js multisite middleware (`MultisiteMiddleware`). |
| `sitecore-jss:common` | `sample apps` | Miscellaneous logging in application templates. |

</details>

<details>
<summary><h2>Advanced options</h2></summary>

When using Node.js, you can change the behavior of debug logging by using any of the following optional environment variables:

| Name | Description |
| --- | --- |
| `DEBUG_HIDE_DATE` | *boolean*<br><br>Whether to hide dates from debug output (non-TTY only).<br><br>default: `false` |
| `DEBUG_COLORS` | *boolean*<br><br>Whether to use colors in the debug output.<br><br>default: `true` |
| `DEBUG_DEPTH` | *number*<br><br>The object inspection depth.<br><br>default: `2` |
| `DEBUG_MULTILINE` | *boolean*<br><br>Whether to pretty-print inspected objects on multiple lines. If not, they are displayed on a single line.<br><br>default: `false` |
| `DEBUG_SHOW_HIDDEN` | *boolean*<br><br>Whether to show hidden properties on inspected objects.<br><br>default: `false` |

</details>