简体   繁体   中英

In Chrome, how can I get the javascript console output to stdout/stderr

I'm using Google Chrome, and have a page that prints some information to the Javascript console - I want to pipe this to a script.

I've found how to display Chrome's stdout on OS X - by running the command below from a Terminal (a new user profile is needed to make sure the command spawns a new application, otherwise we'll open the existing one and get no output).

However, all I'm getting printed to Terminal is internal Chrome information.

Is there a way to get all JS console output to be printed to stdout/stderr so that I can pipe the output of the below command to my script?

TIA!

/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --user-data-dir=temp-dir

  • Enable logging from the command line using the flags:

    --enable-logging --v=1

    This logs everything Chrome does internally, but it also logs all the console.log() messages as well. The log file is called chrome_debug.log and is located in the User Data Directory .

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