简体   繁体   中英

Listen to browser console events and errors

Looking for a way to log on my server all console events shown on my visitor's browser console. Not just what I'm firing with console.log, but everything... Is there a way?

Yes you can just override console method like

var logFn = console.log;

console.log = function(arg1) {
   // do your work on log information
   logFn('your console hacked')
}

console.error = function(arg1) {
       // do your work on error part
       logFn('your console hacked')
    }

you will find on console only one message 'your console hacked' you can customize according to you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM