AngularJS $log.debug is not a function AngularJS $log.debug is not a function angularjs angularjs

AngularJS $log.debug is not a function


The debug method is not enabled by default because not all browsers support console.debug, but you can enable it in the configuration phase of your app with the $logProvider.

'use strict';angular.module('analysis')  .config(function($logProvider){    $logProvider.debugEnabled(true);  })  .controller('AnalysisController', function(    $scope,    $timeout,    $mdSidenav,    $mdComponentRegistry,    $log,    Authentication  ) {    $scope.user = Authentication.user;    // Option #1    //    // $scope.isOpen = function() { return $mdSidenav('right').isOpen(); };    // $scope.toggle = function() { $mdSidenav('right').toggle() };    // Option #2 - See https://github.com/angular/material/issues/974    $scope.toggle = angular.noop;    $scope.isOpen = function() {      return false;    };    $scope.toggleLeft = function() {      $mdSidenav('left').toggle().then(function() {        $log.debug('toggle left is done');      });    };  });


$log's debug method is disabled by default. You need to enable $log from app config phase like below.

app.config(function($logProvider){  $logProvider.debugEnabled(true);});


FYI, I got this same error when I inadvertently reassigned the debug method instead of calling it.

$log.debug = 'My log message'

Instead of:

$log.debug('My log message')

After browsing to the page that had the bad statement, I would get "TypeError: $log.debug is not a function" on my other pages that had log statements.