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

Sitecore Content SDK 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 Content SDK logs are organized under the root namespace `content-sdk`. 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/content-sdk/angular/1x/debug-logging-in-content-sdk-apps.html#UUID-31318852-95bb-00af-bf47-8517b23ccf46_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 `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 [enable 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 `content-sdk:*`. The asterisk behaves as a wildcard.

```text
DEBUG=content-sdk:*
```

You can use [namespaces](https://doc.sitecore.com/sai/en/developers/content-sdk/angular/1x/debug-logging-in-content-sdk-apps.html#UUID-31318852-95bb-00af-bf47-8517b23ccf46_section-idm4588692370507232613361843069 "Namespaces") to selectively show a specific category of log messages, for example, layout service logs.

```text
DEBUG=content-sdk: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=content-sdk:layout,content-sdk: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=content-sdk:*,-content-sdk:layout
```

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

The following table lists all the namespaces available for debug logging in Content SDK apps.

<table style="width:100%;" class="informaltable frame-void rules-rows"><thead><tr><th class="th"><p>Namespace</p></th><th class="th"><p>Description</p></th></tr></thead><tbody><tr><td class="td"><p><code class="code">content-sdk:http</code></p></td><td class="td"><p>HTTP request and response logging for default fetch wrappers.</p></td></tr><tr><td class="td"><p><code class="code">content-sdk:dictionary</code></p></td><td class="td"><p>Trace logging for the dictionary service.</p></td></tr><tr><td class="td"><p><code class="code">content-sdk:layout</code></p></td><td class="td"><p>Trace logging for the layout service.</p></td></tr><tr><td class="td"><p><code class="code">content-sdk:editing</code></p></td><td class="td"><p>Trace logging for SitecoreAI editor integration.</p></td></tr><tr><td class="td"><p><code class="code">content-sdk:sitemap</code></p></td><td class="td"><p>Trace logging for the sitemap service.</p></td></tr><tr><td class="td"><p><code class="code">content-sdk:robots</code></p></td><td class="td"><p>Trace logging for the robots.txt service.</p></td></tr><tr><td class="td"><p><code class="code">content-sdk:redirects</code></p></td><td class="td"><p>Trace logging for the <code class="code">core</code> redirects service and the redirects middleware.</p></td></tr><tr><td class="td"><p><code class="code">content-sdk:errorpages</code></p></td><td class="td"><p>Trace logging for the error pages service.</p></td></tr><tr><td class="td"><p><code class="code">content-sdk:multisite</code></p></td><td class="td"><p>Trace logging for the site info service and multisite middleware.</p></td></tr><tr><td class="td"><p><code class="code">content-sdk:personalize</code></p></td><td class="td"><p>Trace logging for the personalize service and personalize middleware.</p></td></tr><tr><td class="td"><p><code class="code">content-sdk:common</code></p></td><td class="td"><p>Common logging messages used throughout the application.</p></td></tr><tr><td class="td"><p><code class="code">content-sdk:search</code></p></td><td class="td"><p>Trace logging for the search service.</p></td></tr></tbody></table>

</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:

<table style="width:100%;" class="informaltable frame-void rules-rows"><thead><tr><th class="th"><p>Name</p></th><th class="th"><p>Description</p></th></tr></thead><tbody><tr><td class="td"><p><code class="code">DEBUG_HIDE_DATE</code></p></td><td class="td"><p><span class="emphasis"><em>boolean</em></span></p><p>Whether to hide dates from debug output (non-TTY only).</p><p>default: <code class="code">false</code></p></td></tr><tr><td class="td"><p><code class="code">DEBUG_COLORS</code></p></td><td class="td"><p><span class="emphasis"><em>boolean</em></span></p><p>Whether to use colors in the debug output.</p><p>default: <code class="code">true</code></p></td></tr><tr><td class="td"><p><code class="code">DEBUG_DEPTH</code></p></td><td class="td"><p><span class="emphasis"><em>number</em></span></p><p>The object inspection depth.</p><p>default: <code class="code">2</code></p></td></tr><tr><td class="td"><p><code class="code">DEBUG_MULTILINE</code></p></td><td class="td"><p><span class="emphasis"><em>boolean</em></span></p><p>Whether to pretty-print inspected objects on multiple lines. If not, they are displayed on a single line.</p><p>default:&nbsp;<code class="code">false</code></p></td></tr><tr><td class="td"><p><code class="code">DEBUG_SHOW_HIDDEN</code></p></td><td class="td"><p><span class="emphasis"><em>boolean</em></span></p><p>Whether to show hidden properties on inspected objects.</p><p>default: <code class="code">false</code></p></td></tr></tbody></table>

</details>