# How to enable debugging output in Ghost

**URL:** <https://forum.ghost.org/t/how-to-enable-debugging-output-in-ghost/8479>\
**Category:** Developer help\
**Created:** [July 31, 2019, 8:11am UTC](https://forum.ghost.org/t/how-to-enable-debugging-output-in-ghost/8479 "2019-07-31T08:11:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxkoretskyi](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@maxkoretskyi](https://forum.ghost.org/u/maxkoretskyi)\
**Post date:** [July 31, 2019, 8:11am UTC](https://forum.ghost.org/t/how-to-enable-debugging-output-in-ghost/8479/1 "2019-07-31T08:11:04Z")

</div>

As I understand Ghost uses [ghost-ignition](https://github.com/TryGhost/Ignition) to collect debugging information. How do I enable output when running ghost?

For example, yesterday I was debugging sources with `node --inspect-brk current/index.js` to figure out why tags page returns `404`. The problem was that I didn’t have articles with such tags. I discovered that by inspecting an SQL query in `models/plugins/has-posts.js`:

```
const addHasPostsWhere = (tableName, config) => {
    const comparisonField = `${tableName}.id`;

    return function (qb) {
        return qb.whereIn(comparisonField, function () {
            const innerQb = this
                .distinct(`${config.joinTable}.${config.joinTo}`)
                .select()
                .from(config.joinTable)
                .whereRaw(`${config.joinTable}.${config.joinTo} = ${comparisonField}`)
                .join('posts', 'posts.id', `${config.joinTable}.post_id`)
                .andWhere('posts.status', '=', 'published');

            debug(`QUERY has posts: ${innerQb.toSQL().sql}`);

            return innerQb;
        });
    };
};

```

But then I saw this he statement inside:

```
debug(`QUERY has posts: ${innerQb.toSQL().sql}`);

```

Which if enabled would help me figure out the problem faster. How can run Ghost to have an output from these `debug` statements?

---

<div class="post-metadata">

**Author:** ![egg](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/egg/32/1691_2.png) [@egg](https://forum.ghost.org/u/egg)\
**Post date:** [July 31, 2019, 8:15am UTC](https://forum.ghost.org/t/how-to-enable-debugging-output-in-ghost/8479/2 "2019-07-31T08:15:11Z")

</div>

We use the [`debug`](https://www.npmjs.com/package/debug) module inside of ignition.

You enable it by using a `DEBUG` environment variable, e.g.

```auto
# This will enable debugging for everything
DEBUG=* node current/index.js

```

And you can make it more specific like

```auto
# This will enable debugging for the `knex:query` debugger
DEBUG=knex:query node current/index.js

```

You can also comma separate the different debuggers to enable - you’ll find more information in the README of the package linked above!

---

<div class="post-metadata">

**Author:** ![maxkoretskyi](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@maxkoretskyi](https://forum.ghost.org/u/maxkoretskyi)\
**Post date:** [July 31, 2019, 8:22am UTC](https://forum.ghost.org/t/how-to-enable-debugging-output-in-ghost/8479/3 "2019-07-31T08:22:50Z")

</div>

Awesome, thanks for the quick response! I’ll explore this functionality

---

<div class="post-metadata">

**Author:** ![eexit](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/eexit/32/15583_2.png) [@eexit](https://forum.ghost.org/u/eexit)\
**Post date:** [April 19, 2022, 9:27am UTC](https://forum.ghost.org/t/how-to-enable-debugging-output-in-ghost/8479/4 "2022-04-19T09:27:44Z")

</div>

> [@maxkoretskyi](#):
>
> ghost-ignition

Hello,

I noticed the [Ignition](https://github.com/TryGhost/Ignition) project has been archived but there’s no deprecation notice whatsoever.  
What should be used for replacement?

Thanks!

---

<div class="post-metadata">

**Author:** ![TheRoyalFig](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/theroyalfig/32/27771_2.png) [@TheRoyalFig](https://forum.ghost.org/u/TheRoyalFig)\
**Post date:** [April 19, 2022, 2:36pm UTC](https://forum.ghost.org/t/how-to-enable-debugging-output-in-ghost/8479/5 "2022-04-19T14:36:07Z")

</div>

If you’re looking for a way to log your local Ghost instance, I use the following command to start Ghost:

```bash
NODE_ENV=development ghost run

```

In addition to more verbose logging in the console, you can also use the [`{{log}}` helper](https://ghost.org/docs/themes/helpers/log/) to output template data/contexts to the terminal.

I also can never remember this command 😆 so I alias it in my terminal profile to `gbug`:

```bash
alias gbug="NODE_ENV=development ghost run"

```

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [April 19, 2022, 3:30pm UTC](https://forum.ghost.org/t/how-to-enable-debugging-output-in-ghost/8479/6 "2022-04-19T15:30:50Z")

</div>

A shortcut for this is `ghost run -D`!

If you need advanced debug (usually when you’re working on Ghost Core), as Fabien mentioned, you can use the `DEBUG` environment variable

---

<div class="post-metadata">

**Author:** ![RyanF](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ryanf/32/17448_2.png) [@RyanF](https://forum.ghost.org/u/RyanF)\
**Post date:** [April 19, 2022, 3:40pm UTC](https://forum.ghost.org/t/how-to-enable-debugging-output-in-ghost/8479/7 "2022-04-19T15:40:14Z")

</div>

Awesome tip! Thank you @vikaspotluri123

---

<div class="post-metadata">

**Author:** ![eexit](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/eexit/32/15583_2.png) [@eexit](https://forum.ghost.org/u/eexit)\
**Post date:** [April 26, 2022, 7:32am UTC](https://forum.ghost.org/t/how-to-enable-debugging-output-in-ghost/8479/8 "2022-04-26T07:32:09Z")

</div>

Thanks for the answer.

So, in my code, I should replace these code occurrences with just `console.*()`?

Example: replace

```javascript
const debug = require('ghost-ignition').debug('adapter');

// ...

debug('key:', var);

```

By:

```javascript
console.debug('key', var);

```

Thanks!

---

<div class="post-metadata">

**Author:** ![vikaspotluri123](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/vikaspotluri123/32/24_2.png) [@vikaspotluri123](https://forum.ghost.org/u/vikaspotluri123)\
**Post date:** [April 26, 2022, 1:14pm UTC](https://forum.ghost.org/t/how-to-enable-debugging-output-in-ghost/8479/9 "2022-04-26T13:14:04Z")

</div>

If you’re trying to use the Ignition-equivalent of `debug`, that’s part of [`@tryghost/debug`](https://github.com/TryGhost/framework/tree/main/packages/debug). Note that this is just a thin wrapper around the `debug` package so if you don’t need those features, you can just use that.

---

<div class="post-metadata">

**Author:** ![eexit](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/eexit/32/15583_2.png) [@eexit](https://forum.ghost.org/u/eexit)\
**Post date:** [June 8, 2022, 8:35pm UTC](https://forum.ghost.org/t/how-to-enable-debugging-output-in-ghost/8479/10 "2022-06-08T20:35:49Z")

</div>

Thanks a lot, I was able to remove the retired dependency and replace it by the new one.
