# Suppressing console.log messages in production deployment

**URL:** <https://forums.bitovi.com/t/suppressing-console-log-messages-in-production-deployment/887>\
**Category:** StealJS\
**Created:** [May 16, 2018, 9:01am UTC](https://forums.bitovi.com/t/suppressing-console-log-messages-in-production-deployment/887 "2018-05-16T09:01:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![robfoweraker](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/robfoweraker/32/284_2.png) [@robfoweraker](https://forums.bitovi.com/u/robfoweraker)\
**Post date:** [May 16, 2018, 9:01am UTC](https://forums.bitovi.com/t/suppressing-console-log-messages-in-production-deployment/887/1 "2018-05-16T09:01:52Z")

</div>

Hi,

I seem to remember seeing somewhere, that it is possible to suppress console.log messages in production deployment by putting some special comments around them in the JS. These console.log expressions are then removed by StealJS during compilation. I’ve searched but I can no longer find any reference to how this works - maybe I’m just imagining things?

BTW - the migration from Can3 to Can4 has gone really well - we are now back at the bleeding edge of technology!

Cheers  
Rob

---

<div class="post-metadata">

**Author:** ![phillipskevin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/phillipskevin/32/102_2.png) [@phillipskevin](https://forums.bitovi.com/u/phillipskevin)\
**Post date:** [May 16, 2018, 1:37pm UTC](https://forums.bitovi.com/t/suppressing-console-log-messages-in-production-deployment/887/2 "2018-05-16T13:37:34Z")

</div>

Hi @robfoweraker,

There are a few options for doing this.

You can use the [envify](https://stealjs.com/docs/steal-tools.BuildOptions.html) build option and wrap your console statements like this:

```auto
if (process.env.NODE_ENV !== "production") {
  console.log("will only log in development");
}

```

Steal also allows you to remove code wrapped in steal-specific comments like these:

```auto
//!steal-remove-start
console.log("will only log in development");
//!steal-remove-end

```

when you set the [removeDevelopmentCode](https://stealjs.com/docs/steal-tools.transform.options.html) build option.

Lastly, you can use the [can-log/dev](https://canjs.com/doc/can-log/dev.log.html) package, which has the same methods as `console`, but takes care of removing the logs in production mode.

Glad to hear your migration went well!

– Kevin

---

<div class="post-metadata">

**Author:** ![robfoweraker](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/robfoweraker/32/284_2.png) [@robfoweraker](https://forums.bitovi.com/u/robfoweraker)\
**Post date:** [May 16, 2018, 7:58pm UTC](https://forums.bitovi.com/t/suppressing-console-log-messages-in-production-deployment/887/3 "2018-05-16T19:58:46Z")

</div>

Hi Kevin,

Thanks for the answers. There are just too many options, I need to think about it now 😉

Rob

---

<div class="post-metadata">

**Author:** ![phillipskevin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/phillipskevin/32/102_2.png) [@phillipskevin](https://forums.bitovi.com/u/phillipskevin)\
**Post date:** [May 17, 2018, 2:59pm UTC](https://forums.bitovi.com/t/suppressing-console-log-messages-in-production-deployment/887/4 "2018-05-17T14:59:42Z")

</div>

Personally, I would go with the `process.env.NODE_ENV` option. This is the standard that is supported in Node and most module loaders.
