# Remove console logs (release)

**URL:** <https://forum.ionicframework.com/t/remove-console-logs-release/76590>\
**Category:** ionic-v3\
**Created:** [January 18, 2017, 9:09am UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590 "2017-01-18T09:09:39Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oldstadt](https://avatars.discourse-cdn.com/v4/letter/o/c57346/32.png) [@Oldstadt](https://forum.ionicframework.com/u/Oldstadt)\
**Post date:** [January 18, 2017, 9:09am UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590/1 "2017-01-18T09:09:39Z")

</div>

How do I get rid of console logs from an ionic 2 release application?

I am developing an ionic 2 app. When I build the signed release apk for Android and run on a device, I can still attach to the process from `chrome://inspect`, and view console logs.

**I have tried removing the cordova-plugin-console, but that makes no difference.**

On a related issue, I am also able to view decoded HTTPS traffic using `chrome://inspect`.

**Edit:** I found [this](https://www.npmjs.com/package/remove-console-logs) package which claims to do what I want. How can I go about including it into my ionic build process when building release version?

Thanks.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [January 18, 2017, 5:30pm UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590/2 "2017-01-18T17:30:27Z")

</div>

For the most part, you shouldn’t really have to worry about this.  
Since production ios and android builds removed debugging capabilities, no will be able to see these/access them.

---

<div class="post-metadata">

**Author:** ![Oldstadt](https://avatars.discourse-cdn.com/v4/letter/o/c57346/32.png) [@Oldstadt](https://forum.ionicframework.com/u/Oldstadt)\
**Post date:** [January 19, 2017, 6:39am UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590/3 "2017-01-19T06:39:18Z")

</div>

Hi Mike, I am currently testing with Genymotion and can see console logs and private HTTPS traffic if I attach to the release APK with chrome://inspect.

I also tried creating a new project to test and can reproduce with the following steps:

```auto
ionic start -v2 testblank blank
ionic plugin remove cordova-plugin-console
ionic build android --release --prod -- --keystore="..." --alias=...
install on Genymotion and inspect with Chrome

```

```auto
$ ionic info
******************************************************
 Dependency warning - for the CLI to run correctly,
 it is highly recommended to install/upgrade the following:

 Please install your Cordova CLI to version >=4.2.0 `npm install -g cordova`

******************************************************

Your system information:

 You have been opted out of telemetry. To change this, run: cordova telemetry on.
6.4.0

Ionic Framework Version: 2.0.0-rc.5
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 8.1
Node Version: v6.9.2
Xcode version: Not installed

******************************************************
 Dependency warning - for the CLI to run correctly,
 it is highly recommended to install/upgrade the following:

 Please install your Cordova CLI to version >=4.2.0 `npm install -g cordova`

******************************************************

```

Thanks,  
Mike.

---

<div class="post-metadata">

**Author:** ![itsDQ](https://avatars.discourse-cdn.com/v4/letter/i/258eb7/32.png) [@itsDQ](https://forum.ionicframework.com/u/itsDQ)\
**Post date:** [February 9, 2017, 9:31pm UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590/4 "2017-02-09T21:31:08Z")

</div>

As you stated production Android builds removed the debugging capabilities. However when I follow the instructions here [Ionic Publishing](https://ionicframework.com/docs/guide/publishing.html) for `cordova plugin rm cordova-plugin-console --save` (since I have it in my `config.xml`) and then make a production release using `ionic build android --release --prod` the app crashes on startup. I zip aligned and signed the production Android release properly. If I follow the same exact steps omitting `cordova plugin rm cordova-plugin-console --save` the app works as expected and the console logs are not seen. I’m not sure if this is a bug or this is a required plugin in which this should be noted someplace.

Here’s my `ionic info`:

```auto
******************************************************

Your system information:

Cordova CLI: 6.5.0 
Ionic Framework Version: 2.0.1
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.1
ios-deploy version: Not installed
ios-sim version: Not installed
OS: macOS Sierra
Node Version: v7.1.0
Xcode version: Xcode 8.2.1 Build version 8C1002

******************************************************

```

---

<div class="post-metadata">

**Author:** ![ezain](https://avatars.discourse-cdn.com/v4/letter/e/ba9def/32.png) [@ezain](https://forum.ionicframework.com/u/ezain)\
**Post date:** [April 28, 2017, 1:14pm UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590/5 "2017-04-28T13:14:42Z")

</div>

You can use uglifyjs.config.js for drop all console logs.

1. Copy uglifyjs.config.js from node\_modules into your project folder
2. In the new config file set the flag drop\_console to true

```auto
  compress: {
    drop_console: true
  },

```

3 . Set your custom configuration in the package.json

```auto
"config": {
    "ionic_uglifyjs": "uglifyjs.config.js"
  },

```

And that’s all !

---

<div class="post-metadata">

**Author:** ![mich356c](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mich356c/32/105794_2.png) [@mich356c](https://forum.ionicframework.com/u/mich356c)\
**Post date:** [April 28, 2017, 2:15pm UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590/6 "2017-04-28T14:15:10Z")

</div>

Where’d you find this? Is there more? 😮

---

<div class="post-metadata">

**Author:** ![ezain](https://avatars.discourse-cdn.com/v4/letter/e/ba9def/32.png) [@ezain](https://forum.ionicframework.com/u/ezain)\
**Post date:** [April 29, 2017, 9:10am UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590/7 "2017-04-29T09:10:15Z")

</div>

reading docs 😉

uglifyjs compress options: [https://github.com/mishoo/UglifyJS2#compressor-options](https://github.com/mishoo/UglifyJS2#compressor-options)  
ionic-app-scripts custom config: [https://github.com/driftyco/ionic-app-scripts#custom-configuration](https://github.com/driftyco/ionic-app-scripts#custom-configuration)

---

<div class="post-metadata">

**Author:** ![infoproducts](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/infoproducts/32/100372_2.png) [@infoproducts](https://forum.ionicframework.com/u/infoproducts)\
**Post date:** [May 8, 2017, 10:52am UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590/8 "2017-05-08T10:52:22Z")

</div>

I do it like this:

`app/config/uglifyjs.config.js`

```auto
let defaultConfig = require('@ionic/app-scripts/config/uglifyjs.config');

module.exports = Object.assign({}, defaultConfig, {
	compress: Object.assign({}, defaultConfig.compress, {
		drop_console: true,
		drop_debugger: true
	})
});

```

`app/package.json`

```auto
{
...
    "config": {
        "ionic_uglifyjs": "./config/uglifyjs.config.js"
    },
...
}

```

---

<div class="post-metadata">

**Author:** ![Snag](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@Snag](https://forum.ionicframework.com/u/Snag)\
**Post date:** [September 11, 2017, 5:15am UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590/9 "2017-09-11T05:15:20Z")

</div>

But what about PWAs? This still seems to be an issue there

---

<div class="post-metadata">

**Author:** ![skydive](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@skydive](https://forum.ionicframework.com/u/skydive)\
**Post date:** [September 27, 2017, 7:21pm UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590/10 "2017-09-27T19:21:46Z")

</div>

I tried the uglify trick, but logs are still there.I tried several different things, but I can’t get rid of logs in release apk no matter what.

Did anybody managed to make it work?

---

<div class="post-metadata">

**Author:** ![Oliver2000](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/oliver2000/32/101483_2.png) [@Oliver2000](https://forum.ionicframework.com/u/Oliver2000)\
**Post date:** [November 15, 2017, 11:59am UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590/11 "2017-11-15T11:59:55Z")

</div>

> [@infoproducts](#):
>
> drop\_debugger

Can I do something similar with an older Ionic v1 app?

---

<div class="post-metadata">

**Author:** ![guillefd](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/guillefd/32/88180_2.png) [@guillefd](https://forum.ionicframework.com/u/guillefd)\
**Post date:** [November 16, 2017, 8:34pm UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590/12 "2017-11-16T20:34:23Z")

</div>

For someone looking for a quick solution, just add this to src/app/main.ts

```auto
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';

// disable console log
 console.log = function(){};

platformBrowserDynamic().bootstrapModule(AppModule);

```

---

<div class="post-metadata">

**Author:** ![michaelkariv](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@michaelkariv](https://forum.ionicframework.com/u/michaelkariv)\
**Post date:** [March 4, 2018, 6:54am UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590/13 "2018-03-04T06:54:51Z")

</div>

The solution suggested by @guillefd will hide the printouts to console, but performance win will be lesser then when removing calls to console.log()

---

<div class="post-metadata">

**Author:** ![BeliliFahem](https://avatars.discourse-cdn.com/v4/letter/b/8dc957/32.png) [@BeliliFahem](https://forum.ionicframework.com/u/BeliliFahem)\
**Post date:** [December 6, 2019, 10:08am UTC](https://forum.ionicframework.com/t/remove-console-logs-release/76590/14 "2019-12-06T10:08:53Z")

</div>

Is this still true with Capacitor / Ionic4 ?
