Firefox Console Log Disabled
Recently, I was working on a legacy project that it has used the JavaScript framework called Dojo Toolkit
. During the development, I opened the Web Console
from the browser Firefox as usual, I expected that some logs would be printed because I used many console.log
for debugging purpose. However, what I got was an warning message
The Web Console logging API (console.log, console.info, console.warn, console.error) has been disabled by a script on this page
So I went to the google and found this good post from Stack Overflow (of course it is) explains why the console.log
is not working as expected. The reason is quite simple because some scripts (JavaScript) in your website overrides the window.console
global variable. That's it, what we have to do is to find where is that script(s) and comment or delete the lines that overriding the console
variable.
How to do it? #
First, I went to the IDE (I use Eclipse) and searched some keywords like the "log"
, "info"
or console
and found the following snippet in a file named dojo.js
.
if((!this["console"])||(!console["firebug"])){
this.console = {};
}
var cn = [
"assert", "count", "debug", "dir", "dirxml", "error", "group",
"groupEnd", "info", "log", "profile", "profileEnd", "time",
"timeEnd", "trace", "warn"
];
var i=0, tn;
while((tn=cn[i++])){
if(!console[tn]){
console[tn] = function(){};
}
}
I commented the above code but it still did not work. It is because I missed the firebug
thing so I removed the firebug
scripts as well and it worked perfectly. By the way, firebug
is deprecated long time ago, therefore it is safe to remove it. But remember to revert the above changes when you done the development or user acceptance test and never change anything that is unrelated to the requirements.
- Previous: Delegation vs. Forwarding
- Next: Java HttpURLConnection Example