最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

In Chrome, how can I get the javascript console output to stdoutstderr - Stack Overflow

programmeradmin6浏览0评论

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

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

Share Improve this question asked Aug 23, 2016 at 11:01 AnthonyAnthony 3031 gold badge2 silver badges7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 20
  • Enable logging from the command line using the flags:

    --enable-logging --v=stderr

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.

发布评论

评论列表(0)

  1. 暂无评论