Shir Gans
Shir Gans

Reputation: 2027

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?

Upvotes: 2

Views: 1575

Answers (1)

Birbal Singh
Birbal Singh

Reputation: 1072

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.

Upvotes: 1

Related Questions