Can anyone shed some light on how to disable console.log()
on production? I have seen achievements as below:
To stop the console logging, use the no logging console global configuration command (highly recommended for routers that are not usually accessed through the console port) or you might want to limit the amount of messages sent to the console with the logging console level configuration command (for example, logging ...
To disable Javascript console, we need to throw an exception in the get accessor by checking if the property attached by chrome developer tool exists. With this script above, user won't be allowed to enter Javascript in the console. It also blocks auto-complete in console too. Thank you friends!
The Yellow warning box in React Native can be both helpful and annoying. There are many errors that can be ignored but end up blocking necessary pieces of the application. To disable the yellow box place console. disableYellowBox = true; anywhere in your application.
Are you using some kind of module bundler ? In webpack you have option to drop_console in build. What drop console does is remove all console.log statements from your code. There is also npm module for same please take a look. https://www.npmjs.com/package/babel-plugin-transform-remove-console This is a bagel plugin and if you have babel setup you can use it.
If all this doesn't meet your requirements. You can simply override console.log statement or use custom logger as other answers have suggested.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With