2

I'm running a Chrome kiosk and want to retain and aggregate logs. The Chrome docs say that you can use --enable-logging --v=1 and it will log the to the chrome_debug.log file. Doing this creates a log, but it's all system-level stuff within Chrome and not the site-specific logs. Is there a way to capture all my console.log/info/warn statements straight to a file? Or do I need to engineer something?

1 Answer 1

2

As long as you are in control of the code, or you can inject code, you can override console.log to collect the messages.

var aggrLog = '';
(function(){
    var oldLog = console.log;
    console.log = function (message) {
        aggrLog += Array.prototype.join.call(arguments, ' ') + '\n';
        oldLog.apply(console, arguments);
    };
})();

This will aggregate all the console.log in variable aggrLog.

credit: https://stackoverflow.com/questions/11403107/capturing-javascript-console-log

Modern browsers allows to save local data to file, you'll need a trigger to decide when to save. see more here:

https://stackoverflow.com/questions/21012580/is-it-possible-to-write-data-to-file-using-only-javascript

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.