245

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 main page, so functions are not redefined in some code console.log doesn't work

5
  • 16
    Make sure you have some value typed in the filter field. Commented Jun 5, 2018 at 15:10
  • 2
    For anyone doing web development with Flask: I ran into this same issue -- adding console.log statements to my Javascript, and nothing was displaying in the console. Problem turned out to be due to browser caching... it wasn't seeing my added log statements. Solution is a hard refresh (CTRL+F5 instead of F5 on Windows). Hope that helps someone else with the same issue! Commented Oct 3, 2019 at 17:55
  • 8
    i accidently had some text in the filter field Commented Dec 13, 2019 at 15:00
  • 1
    2021 and still the same problem. So every time I want to console.log something I need to press Ctrl+F5. Commented Jan 27, 2021 at 16:03
  • Sometimes the website overrides the default (window.) console.log :) Commented Jun 9, 2021 at 13:15

27 Answers 27

424

Click “Default levels” and make sure that "Verbose" is checked. By default it is only set to show Errors and Warnings

I came here with the same problem :/

Sign up to request clarification or add additional context in comments.

14 Comments

Thanks...I just thought the new version chrome does not work well !
@NikhilPatil not stupid at all. That's just a terrible default setting.
Just a note for later versions of Chrome: it looks like it's a dropdown at the top now, and you'll want to change it to "Verbose" to see everything.
This solved my slightly different error: I had accidentally typed something into the "Filter" box (next to the levels dropdown) the day before.
i have checked all levels still not working ?
|
58

For completeness: In the current version of chrome, the setting is no longer at the bottom but can be found when clicking the "Filter" icon at the top of the console tab (second icon from the left)

1 Comment

Why this answer is not the top voted?
47

As of today, the user interface (UI) of developer tools in Google Chrome has changed. It has changed in terms of the place in UI where we select log level of the logs being shown in the console. There is a Level drop-down to the right of Filter input box. Supported values in the drop-down are:

  • Verbose
  • Info
  • Warnings
  • Errors

The default selection in the drop-down is Info (Refer screenshot).

enter image description here

Any log statement whose severity is equal or higher than the selected log-level then only, it will get displayed in the Console tab e.g. if selected log level is Info then any log statement having log-level Info, Warning or Error will get displayed in the Console tab.

When I changed it to Verbose then log statements corresponding to console.debug and console.log started showing-up in the Console tab. Till the time Info level was selected, log statements were not getting displayed.

Comments

39

Make sure that the "Filter" input is left blank and nothing is written intentionally or by mistake. That was it in my case :P

enter image description here

3 Comments

It remembers this across sessions -tripped me up as well.
OPMG I do this all the time! I wish it was more obvious. THANK YOU
I cannot believe after well over a decade of web development that this was the cause of my "broken console.log()" for the last few days. Thanks for this. 😂
32

Same issue, but I just cleared my settings. I went into Settings > Preferences and Clicked [Restore defaults and reload]. Just remember what your settings were.

enter image description here

4 Comments

I spent days on debugging this issue, and this solution worked like magic!
I used this but I ticked disable cache under Network and that then worked
I spent 3-4 hours trying to work out why Next.js wasn't running any code on the client side while working on a technical assignment for a new job, turns out this was all that was wrong. I have no idea why it was broken but the SO post may have saved my chances of getting an amazing job
If you can't find these settings, press F1 inside the dev tools.
13

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.

Comments

12

There could also be some filters applied to the console. Remove them.

Comments

7

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.

1 Comment

in my case it was 3rd-side ad script, it is blocking console, then trying to load ad, then restoring console, but ad was blocked by CORS, and no console.log restoration occured
7

Another tip, why console.log doesn't works is that the Filter search field must be empty.

enter image description here

1 Comment

This actually works for me. The search field in the dev tool of my browser somehow has some text in it. After removing it, console.log("xxx") starts to output the text.
6

In my case was webpack having the UglifyPlugin running with drop_console: true set

2 Comments

I have the same problem. uglify is removing the logging. Thank you
Is it possible to restore it once a site script drops it like that?
6

As of July 2020 the Chrome UI has changed once again and the logging level dropdown doesn't seem to do anything now.

Instead, there's a new pane to the left of the main console pane, which may have got unintentionally set to one of the restrictive logging levels:

enter image description here

Select the top category (messages) to reveal all the logging:

enter image description here

EDIT: EVEN THEN Chrome seems to add things to the Filter box, which again loses some logging, so you must CLEAR THE FILTER BOX TOO!

(Filter box is at the top of both my pics above, under "Network conditions"; you can see that it has some contents about "urlwebpack" which I didn't put there!)

1 Comment

THE new answer. It shouldn't be this hard ಠಿ_ಠ
5

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.

1 Comment

forum.xda-developers.com is an example of a prominent site that disables console.log.
5

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

Please see screenshot:

enter image description here

1 Comment

This just duplicates the accepted answer with a screenshot. You could make a better contribution by suggesting an edit to the currently accepted answer to include your screenshot.
4

If you are seeing(3 messages are hidden by filters. Show all messages.) then click on show all message link in Chrome dev tool console.

Because if this option enabled by mistake the console.log("") message will show but this will in in hidden state.

Comments

4

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,

enter image description here

Comments

3

In my case it was just an old cached Javascript file. After clearing the cache I saw my logs.

Comments

3

Selecting verbose fixed it for meVerbose

Comments

3

In my case, i was not able to see logs because there is some text in Filter field, which caused results of console.log to disappear. Once we clear text in Filter field, it should show.

1 Comment

Thanks - fixed it for me!
2

see if something show on the filter box in console ,it means something override your script clear the filter box and check again. i my case this is the issue.

Comments

1

In my case, the solution was for me to click on "Top" and select debuggerWorker.aca... localhost:8081

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
1

React Dev Tools Extension Causing the Issue

If you have React Developer Tools chrome extension installed, unistalling it fixed my issue. Obviously this might be a difficult trade off.

I never used them so deleting them solved it in my case.

enter image description here

2 Comments

Installed for... VSCode? Node Package Manager? Something else?
@TekuConcept as chrome extension.
1

In my case console.log was returning ƒ (){}

Not really sure why, but I realized that I had to call window.showConsole() for it to come back as the native code and be able to see the logs.

Comments

0

This worked for me. In the console section, go to the settings on top right. There select preserve log and Log XMLHttpsRequests.

Comments

0

Make sure the filter box is empty

Comments

0

Make sure that your webpack configuration file does not include any statement to drop console logs. (e.g drop_console: true).

If it does, change that statement and restart your project. (e.g. npm run start) Recompiling instead of restarting would have no effect since webpack configurations are only read in the start.

Comments

0

In my case, the cause is one chrome plugin.

You can enter incognito window by cmd + shift + N, check if the problem disappear

incognito window is a envriment without chrome plugins

Comments

0

enter image description hereIt could be that you have deselected 'messages' on the left, under 'top'. I fixed mine immediately, reselected it. See the attached screenshot. Thanks.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.