2

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?

Shir Gans
  • 1,976
  • 3
  • 23
  • 40
  • Something like this? https://stackoverflow.com/questions/8000009/is-there-a-way-in-javascript-to-listen-console-events – blueren Nov 28 '17 at 09:53
  • Possible duplicate of [Is there a way in JavaScript to listen console events?](https://stackoverflow.com/questions/8000009/is-there-a-way-in-javascript-to-listen-console-events) – blueren Nov 28 '17 at 09:53
  • Refer this: –  Nov 28 '17 at 09:54

1 Answers1

1

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.

Birbal Singh
  • 1,062
  • 7
  • 16