Chrome: console.log, console.debug are not working

前端 未结 20 885
别那么骄傲
别那么骄傲 2020-11-29 02:52

Console.log and debug not printing, only return undefined. Why it can be? I\'ve tried to re-install chrome, but it doesn\'t help.

Here is screenshot from chrome\'s m

相关标签:
20条回答
  • 2020-11-29 03:32

    As of today, the UI of developer tools in Google chrome has changed where we select the log level of log statements being shown in the console. There is a logging level drop down beside "Filter" text box. Supported values are Verbose, Info, Warnings and Errors with Info being the default selection.

    Any log whose severity is equal or higher will get shown in the "Console" tab e.g. if selected log level is Info then all the logs having level Info, Warning and Error will get displayed in console.

    When I changed it to Verbose then my console.debug and console.log statements started showing up in the console. Till the time Info level was selected they were not getting shown.

    0 讨论(0)
  • 2020-11-29 03:32

    I'm working on a site where some JS (or other) code is preventing console.log from working (console.log is probably overwritten). You can test this by checking if console.log works on a different page (like this one).

    I don't have time to investigate further right now so used alert("something is: "+something) to get the info I wanted from a snippet I needed to run.

    0 讨论(0)
  • 2020-11-29 03:35

    Sometimes the simplest things trip us up...

    Type console.log in the console and check what function gets returned. If you see ƒ log() { [native code] } then it's something else. If you see ƒ (){} then somewhere down the line the native console.log function was changed.

    Was working on a client's site today and that was the issue. If that's the case, you can either manually restore the console.log function or use console.dir() or console.warn() instead.

    If you see ƒ (){} then there is a possibility that sometime console stops working due to some functionality you have added in your javascript. so first close all tabs restart chrome and in a new tab just typ1 console.log('hi'); if it prints that then it confirms that the problem is there in your script code. if not then restore the cosole.log.

    To restore the console in new tab go to console and type delete window.console it will return true after that restart the chrome and you are good to go.

    0 讨论(0)
  • 2020-11-29 03:36

    I experienced the same problem. The solution for me was to disable Firebug because Firebug was intercepting the logs in the background resulting in no logs being shown in the Chrome console.

    0 讨论(0)
  • 2020-11-29 03:36

    Click “Default levels” right next to filter and do make sure that "Info" is checked.

    Please see screenshot:

    enter image description here

    0 讨论(0)
  • 2020-11-29 03:42

    In my case preserve logs do the trick. I did everything to show the logs, but it goes away. I checked it and it works,

    0 讨论(0)
提交回复
热议问题