AngularJS: How to turn on and off $log.debug

If you’re using $log.debug() for your AngularJS debugging, there’s a very easy way to stop those messages appearing in your browser console when you are ready to release – without commenting out every line.

Simply add $logProvider.debugEnabled(false); to the config section of your main app file. Then use true when you’re ready to make them visible again. Don’t forget to pass $logProvider as a parameter to the config function.

A basic example would look like the following:

Note that this does not affect the other message types such as .log(), .info(), etc.

This entry was posted in Design/Dev and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *