12

I've been looking everywhere trying to find a way to modify the behavior of the developer tools console logging in Google Chrome. I've come up short.

The console, by default, does not show each and every time logged. It appears to be keeping a tally of the number of times that the same message is sent to the log. This does not help when you are logging items to verify or debug workflow in a web application.

If I were to log:

1
2
1
1
2
3

I expect to see just that, but what you get is more like:

(3) 1
(2) 2
    3

Is there any way to change this behavior and force the console to show you each and every item that has been logged?

Thank you,

JDF

Josh Lee
  • 171,072
  • 38
  • 269
  • 275
JDF
  • 193
  • 1
  • 7
  • 1
    If it's behaving that way, it's a bug. Chrome should only collapse identical consecutive rows, which is fine unless you're doing ASCII art in the console or something. On my copy of Chrome, this works as intended, NOT the way you describe: [1,2,1,1,2,3].forEach(function(x){console.log(x);}); – yonran Apr 07 '11 at 22:56
  • 1
    Chrome treats console.log('{a:1}); console.log({a:42}) as duplicates and collapses them. Seriously annoying, makes logging near useless. It'd be fine to collapse entries IF YOU COULD EXPAND THEM MANUALLY. – enigment Jan 12 '13 at 20:31
  • Doesn't do that for me. If you want to log objects you can use `console.dir({a:2});` which does give you the entire expandable object instead of converting it to a string – Jason Goemaat Sep 07 '14 at 02:01
  • 1
    If you log those numbers in that order, you should get `1`, `2`, `(2) 1`, `2`, and `3`. Try it out: `for(var i=0;i<6;i++){console.log([1,2,1,1,2,3][i]);}` You can always enable timestamps and check by the times the order they came in. If you were to get `(3) 1` it would be a bug. I think you're not logging things in the order you think. – Jason Goemaat Feb 07 '15 at 01:43

3 Answers3

16

In your Devtools Console:

  1. press the combination CTRL+SHIFT+P.
  2. Write: "show timestamps"
  3. Select it!
  4. Done!

Each output to the console, will have its own line!

ajaysinghdav10d
  • 1,771
  • 3
  • 23
  • 33
colxi
  • 7,640
  • 2
  • 45
  • 43
5

If you click on the cog on the top right of the console window, you are given the option to "Group similar", which is probably checked, if you un-check this, it will show each line separately.

example console with cog

Rich S
  • 3,248
  • 3
  • 28
  • 49
  • 3
    for whatever reason, this does not work for me. the timestamp solution does – Jona Aug 03 '19 at 21:24
  • @jona is what way didn't it work? do you not have the cog or the option? maybe your version of Chrome is different. – Rich S Aug 05 '19 at 08:48
  • definitely latest version of chrome, i see the "Group similar" checkbox, check it, restart chrome, all the basics - just doesn't work :shrug: – Jona Aug 06 '19 at 22:04
  • maybe the messages are slightly different? do you have a screen shot of the messages area? – Rich S Aug 07 '19 at 15:13
3

Well, I appear to have found a decent enough work around... I modified my logging function to the following:

function WriteToLog(msg, clear) {
    try {
        var now = new Date();
        if (clear) {
            console.clear();
        }
        console.log('(' + now.getTime() + ') - ' + msg);
    } catch (e) {

    }
}

This will get the number of milliseconds since 1/1/1970... Which should be distinct enough for logging any process on any computer I will own in the near future. :)

It makes the logs a little more difficult to read, and the value is pretty much useless... but it is distinct enough to circumvent the default tally behavior.

Thanks for looking. I hope I'm not the only one who seriously dislikes this feature.

Betlista
  • 10,327
  • 13
  • 69
  • 110
JDF
  • 193
  • 1
  • 7