4

Recently I read a query about "What does console.log do" and I read an answer, tried using it and found that despite the answer stating that it outputs to the console in googles browser, I just tried it and I get no output.

I did try this code:

function put(p){
if ( window.console && window.console.log ) {
        console.log(p); // console is available
    }else{
        alert(p);
    }
}

BUT... I get neither console output or alert and furthermore .log is a Math property, what gives with that?

Mark Giblin
  • 1,086
  • 2
  • 13
  • 20

4 Answers4

11

Make sure that in the Developer Tools the Filter in the console section is set to All or Logs...

I had a similar experience where I couldn't see any of my console.log output and it was because the console was set to filter on Errors only... All the log entries were there - they just weren't visible.

Bonus marks: you can also Ctrl + Click to select multiple filters (Errors + Logs for example).

Boycs
  • 5,610
  • 2
  • 28
  • 23
0

Press F12 and look at in Developer Tools: Console. I tried your code just now, works fine for me -- Chrome version 30.0.

Since you're after console logging, not mathematical logarithms, perhaps you could stop going on about there being similarly-named function in the Math object. It's not relevant here whatsoever.

You're also coming across just a little shouty. console.log() works fine, and your question didn't indicate that you knew where to look. This is totally your problem, but I'm trying to help you. I can obviously only go on the information you provide, and I can't say your initial question was written very clearly.

It appears, since the snippet of code you posted works here absolutely fine, that your calling code & containing (which you haven't posted) would be the cause of the problem. You should debug these, to find out what's going wrong.

Do you know how to use the Chrome debugger? Are there any error messages showing in Chrome or on the console?

Test it on a simple page if necessary, to rule out other errors in the page/ or surrounding context breaking it. One common mistakes is declare functions in a jQuery ready handler or similar, and then try & access them globally. Make sure your logging function is actually global (outside any other function(){} or object {} blocks).

Lastly, it's good to have a logging function for portability (I have one myself) but put() is not a good name for it. Naming it consoleLog() or log() would be better.

Thomas W
  • 13,940
  • 4
  • 58
  • 76
  • 1
    No, you have not understood my query, 1. no output from my function despite the testiment in other users queries that console.log output goes to the console, it appears not to, so whats going wrong and 2. I know I am not after Math.log but .log is a property of the Math object therefore why no Javascript error??? I already know where the console is as well, like I said NO OUTPUT! – Mark Giblin Oct 25 '13 at 00:41
  • Hi @MarkGiblin -- the posted code works fine, your fault is elsewhere, and see my edited answer for diagnostic tips & a little advice. – Thomas W Oct 26 '13 at 01:51
  • I'm observing the same issue with "Google Chrome Version 39.0.2171.95 (64-bit)" and Chromium "Version 39.0.2171.65 Built on Ubuntu 14.04, running on LinuxMint 17 (64-bit)". It is reproduced on some pages(!) of some sites. No error output, no console.log output. Can't fix that with filters or other devtools settings. Tried to restore settings to default - has not helped. – humkins Jan 04 '15 at 05:41
  • I eventually had an update that resolved the matter. I am going with the notion that like built in obsolescence, google force issues and break their product to get people to move on and upgrade. – Mark Giblin Jan 17 '17 at 10:11
0

Had the same issue .

Make sure your using de right path when you try import thing's .

Example whit my issue :

Wrong path ----> ** import normalizedData from 'normalizr'; **

Right path ---> ** import normalizedData from '../schemas/index.js'; **

0

I had also faced the same problem. Make sure you apply no filter in the console. It worked for me.