javascriptinternet-explorerloggingie-developer-toolsfirebug-lite

console.log() is defined but doesn't log in IE - empty console


Javascript on a page in Internet Explorer (8 and 9) with Developer Tools open reaches console.log(), which is defined - but nothing appears in the actual log.

Things tried:

So the console is there and active, but no console messages show up in the actual console (on either the Script tab or the Console tab).

What else could stop console.log() from actually logging anything, even when Developer Tools is open and console.log is a defined function?


Solution

  • The culprit in this case turned out to be, of all things, firebug lite.

    My test dev pages often include this to (ironically) aid certain types of debugging in IE:

    <!--[if IE]>
    <script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script>
    <![endif]-->
    

    Since it appears in text editors as a comment, it's easy to accidentally overlook.

    Alerting alert(console.log); before and after shows firebug lite changes the console.log function from the native code to this:

    function(){return f.apply(c,arguments)}
    

    ...which for some reason (at the moment, here) then does nothing.

    Without Firebug Lite getting involved, alert(console.log); in IE gives this:

    function log() {
    [native code]
    }
    

    ...and does its usual trick of logging if f12 Dev Tools is open and crashing if it isn't.