Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FireBug problem: Can't use console.log

I have a problem with the current version of FireBug.

Firefox: 3.6.13
Firebug: 1.6.0 and 1.6.1b1 (tried both)

My Javascript can't use console.log (or any console at all) to output debug messages. I'm not sure when it stopped working, but for now I get an "console is not defined" when I try to access it or a message popup when I run this code:

if (console == undefined) {
    alert(1);
}

I had the latest FirePHP extension (DeveloperCompanion) installed but removed it to see if that was causing the problem. Didn't change anything though.

Any ideas? Is this happening to someone else, too?

[UPDATE]

Looks like my problem was actually caused by something else: I use jQuery and have all my code wrapped in $(function() {.....}); to make it run after the page has been rendered.

What I didn't consider is that then the code runs in another scope. console is not available in that scope.

To use the console I have to call window.console.log('bla');.

like image 200
BlaM Avatar asked Dec 17 '10 09:12

BlaM


4 Answers

I did a disable and remove of firebug plugin and then re-installed it. After that check the "All" option under the "Console" tab. In my case the output was getting echoed there after the re-install of the plugin.

like image 127
Srini V Avatar answered Oct 22 '22 17:10

Srini V


Had the same problem, the suggested solutions did'nt work. I solved it by resettting the Firebug options.

Firebugmenu (the bug icon), Options, 'Reset all firebug options'

After this, the console.log('hello'); test worked and so did my loggings.

like image 32
peter Avatar answered Oct 22 '22 16:10

peter


Firebug's console object is only available if Firebug is open. If you have Firebug closed and you load a page with console.log() calls, then they'll throw errors.

Open the Firebug window and refresh the page.

If that still doesn't work, go to Firebug's console tab and try typing console.log('hello'); in the console input area and see if it works from there. That really ought to work.

If even that doesn't work then it sounds like you have a broken Firebug installation; you may need to re-install.

like image 2
Spudley Avatar answered Oct 22 '22 16:10

Spudley


My console.log also stopped working today, but simply restart of browser solved the issue, no need to re-install.

like image 1
Mauno Vähä Avatar answered Oct 22 '22 17:10

Mauno Vähä