本文介绍了将Chrome中的console.log保存到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道有一种方法可以将Chrome中的console.log输出保存到文件中?或者如何从控制台复制文本?

Does anyone know of a way to save the console.log output in Chrome to a file? Or how to copy the text out of the console?

假设您正在运行几个小时的功能测试,并且您有数千行console.log输出铬。

Say you are running a few hours of functional tests and you've got thousands of lines of console.log output in Chrome. How do you save it or export it?

推荐答案

我需要做同样的事情,这是我发现的解决方案: / p>

I needed to do the same thing and this is the solution I found:


  1. 启用从命令行使用以下标志:

  1. Enable logging from the command line using the flags:

- enable-logging --v = 1

这会记录Chrome在内部执行的所有操作,但也会记录所有 console.log()消息。日志文件称为 chrome_debug.log ,位于

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.

过滤日志文件。 CONSOLE(\d +)

Filter the log file you get for lines with CONSOLE(\d+).

请注意,控制台日志不会出现 - incognito

Note that console logs do not appear with --incognito.

这篇关于将Chrome中的console.log保存到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!