Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript, Losing console.log between url posts

I am trying to watch my javascript code using the console.log(text) command - and it does work... but the console gets flushed everytime the url changes.

Is there any way to persist my console logs between page changes?

like image 331
Ciel Avatar asked Jun 08 '11 14:06

Ciel


People also ask

How do I stop my console from clearing?

You need to open the developer tools with Ctrl + Alt (or Cmd + Option) + I. As of Chrome 70 (and maybe before that) the settings cog is at the top right of the console window. Click it, and then click 'Preserve log'.

How does console log work in JavaScript?

log() with Examples. The console. log() is a function in JavaScript which is used to print any kind of variables defined before in it or to just print any message that needs to be displayed to the user.

What is the output of console log a?

log() The console. log() method outputs a message to the web console. The message may be a single string (with optional substitution values), or it may be any one or more JavaScript objects.


4 Answers

Click on the bottom-right corner gear icon in the Chrome developers tool, check 'Preserve log upon navigation' option and you are done.

like image 110
SapC Avatar answered Nov 02 '22 06:11

SapC


For the record, these days both Firefox and Chrome have 'persist' options in their inspectors / conosole. You need to right click in the console window and then select the relevant option tfrom the popup menu.

like image 45
gotofritz Avatar answered Nov 02 '22 07:11

gotofritz


There isn't a way to do this yet but from what I've read it is a future feature they will implement. Here is the Issue ticket on it: http://code.google.com/p/chromium/issues/detail?id=77058


EDIT: Chrome has implemented this feature. Read the answer below

like image 29
scrappedcola Avatar answered Nov 02 '22 08:11

scrappedcola


There's only 1 way that I know of, but not with Chrome: With the built-in Web Inspector in Firefox 4+, which doesn't flush the logs between pages.

@scrappedcola notes that Firebug does this as well, but I'm referring to the built-in inspector.

like image 25
Yahel Avatar answered Nov 02 '22 08:11

Yahel