Browser console.log Not Working, No Output
console.log is invalid, no corresponding output in the console.
Investigation Process
The first reaction was that browser extensions might be the issue, so I disabled all extensions.
Then I checked whether there was a problem with webpack configuration, such as incorrectly minifying code in development environment causing
console.logto be removed.The first two steps didn't find the problem, and only this project had the output issue. After being confused for a while, I decided to check if
console.loghad been hijacked and overwritten.Directly typed in the console:
console.log
// output: function(){}Case solved, the console object was hijacked and overwritten. The rest was to find out where it was overwritten.
Conclusion
It turned out that a portion of the code in the HTML template (scripts directly written into the HTML) was pasted after being compressed and obfuscated using a third-party tool.
The obfuscated code overwrote the methods in console, presumably to prevent users from debugging maliciously.